8000 Add code to disable batch_delete for GCS by lesandie · Pull Request #1 · Altinity/s3gc · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,28 @@ If dryrun is set together with collectonly, error is raised.
python3 s3gc.py --help
```
### typical usage
#### all together
#### all together with dry-run
for https://altinity-clickhouse-data-demo20565656565620663600000001.s3.amazonaws.com/github
```
S3GC_S3ACCESSKEY=sdfasfaerasasf S3GC_S3SECRETKEY=werqwsdfqwersdfasf S3GC_S3IP=s3.amazonaws.com S3GC_S3PORT=443 S3GC_S3REGION=us-east-1 S3GC_S3BUCKET=altinity-clickhouse-data-demo20565656565620663600000001 S3GC_S3PATH=github/ S3GC_S3SECURE_FLAG=true python3 ./s3gc.py --verbose
S3GC_S3ACCESSKEY=sdfasfaerasasf S3GC_S3SECRETKEY=werqwsdfqwersdfasf S3GC_S3IP=s3.amazonaws.com S3GC_S3PORT=443 S3GC_S3REGION=us-east-1 S3GC_S3BUCKET=altinity-clickhouse-data-demo20565656565620663600000001 S3GC_S3PATH=github/ S3GC_S3SECURE_FLAG=true python3 ./s3gc.py --verbose --dry-run
```
#### GCS and object storage that do not support batch delete operations
```
S3GC_S3ACCESSKEY=GOOG1xxxxxxxxx \
S3GC_S3SECRETKEY=xxxxxxxxxxx \
S3GC_S3IP=storage.googleapis.com \
S3GC_S3PORT=443 \
S3GC_S3BUCKET=opensystems-altinity-main-disk \
S3GC_S3PATH=chi-main-main-0-0/ \
S3GC_S3SECURE_FLAG=true \
S3GC_S3DISKNAME=gcs \
python3 ./s3gc.py --verbose --use-remove-objects=false
```

GCS_HMAC_KEY = S3GC_S3ACCESSKEY
GCS_HMAC_SECRET = S3GC_S3SECRETKEY


#### collect only
```
S3GC_S3PORT=19000 S3GC_S3ACCESSKEY=minio99 S3GC_S3SECRETKEY=minio123 python3 ./s3gc.py --verbose --collectonly
Expand Down Expand Up @@ -64,5 +81,6 @@ object last modified in auxiliary table
useage command line parameter

## to do list
1. option to avoid `remove_objects` which is reportedly not supported by GCE
2. concurrency
~~1. option to avoid `remove_objects` which is reportedly not supported by GCE~~

2. concurrency / async
33 changes: 27 additions & 6 deletions s3gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@
default=False,
help="drop collecttable and recreate; beware of ClickHouse DROP TABLE constraints",
)
parser.add_argument(
"--useremoveobjects",
"--use-remove-objects",
dest="use_remove_objects",
type=bool,
default=True,
help="use remove_objects (not supported by GCE). Set it to false to use remove_object",
)
parser.add_argument(
"--non-interactive",
"--noninteractive",
Expand Down Expand Up @@ -663,19 +671,32 @@ def make_antijoin(calc_only=False, sample=None):
with ch_client.query_row_block_stream(antijoin) as stream:
for block in stream:
objects_to_remove = []
object_to_remove = []
for row in block:
logger.debug(
f"{'removing' if not args.dryrun_flag else 'would remove if no dryrun flag'} {row[0]} of size {row[1]}"
)
objects_to_remove.append(DeleteObject(row[0]))
if args.use_remove_objects:
objects_to_remove.append(DeleteObject(row[0]))
else:
object_to_remove.append(row[0])
objs.append([row[0], row[1], row[2], False])
total_size += row[1]
if not args.dryrun_flag:
errors = minio_client.remove_objects(
args.s3bucket, objects_to_remove
)
for error in errors:
logger.info(f"error occurred when deleting object {error}")
if args.use_remove_objects:
errors = minio_client.remove_objects(
args.s3bucket, objects_to_remove
)
for error in errors:
logger.info(f"error occurred when deleting object via remove_objects {error}")
else:
for object_path in object_to_remove:
try:
minio_client.remove_object(
args.s3bucket, object_path
)
except Exception as error:
logger.info(f"error occurred when deleting object {object_path} via remove_object {error}")

num_removed += len(objects_to_remove)

Expand Down
0