Skip to content

Commit 2ae1ec7

Browse files
committed
Cheaper GC
1 parent 2fc6a3c commit 2ae1ec7

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

storage/gcp/gcp.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ func (s *spannerCoordinator) publishCheckpoint(ctx context.Context, minStaleActi
11741174
// needlessly attempt to GC over regions which have already been cleaned.
11751175
func (s *spannerCoordinator) garbageCollect(ctx context.Context, treeSize uint64, maxBundles uint, deleteWithPrefix func(ctx context.Context, prefix string) error, entriesPath func(uint64, uint8) string) error {
11761176
// number of concurrent GCS deletes to perform while collecting garbage.
1177-
const numWorkers = 5
1177+
const numWorkers = 1
11781178

11791179
_, err := s.dbPool.ReadWriteTransactionWithOptions(ctx, func(ctx context.Context, txn *spanner.ReadWriteTransaction) error {
11801180
row, err := txn.ReadRowWithOptions(ctx, "GCCoord", spanner.Key{0}, []string{"fromSize"}, &spanner.ReadOptions{LockHint: spannerpb.ReadRequest_LOCK_HINT_EXCLUSIVE})
@@ -1366,7 +1366,14 @@ func (s *gcsStorage) deleteObjectsWithPrefix(ctx context.Context, objPrefix stri
13661366
bkt := s.gcsClient.Bucket(s.bucket)
13671367

13681368
errs := []error(nil)
1369-
it := bkt.Objects(ctx, &gcs.Query{Prefix: objPrefix})
1369+
q := &gcs.Query{
1370+
Prefix: objPrefix,
1371+
Projection: gcs.ProjectionNoACL,
1372+
}
1373+
if err := q.SetAttrSelection([]string{"Name"}); err != nil {
1374+
return fmt.Errorf("failed to set attr selection: %v", err)
1375+
}
1376+
it := bkt.Objects(ctx, q)
13701377
for {
13711378
attr, err := it.Next()
13721379
if err != nil {
@@ -1485,7 +1492,7 @@ func (m *MigrationStorage) IntegratedSize(ctx context.Context) (uint64, error) {
14851492

14861493
func (m *MigrationStorage) fetchLeafHashes(ctx context.Context, from, to, sourceSize uint64) ([][]byte, error) {
14871494
// TODO(al): Make this configurable.
1488-
const maxBundles = 300
1495+
const maxBundles = 100
14891496

14901497
toBeAdded := sync.Map{}
14911498
eg := errgroup.Group{}

0 commit comments

Comments
 (0)