Skip to content

Commit

Permalink
chore: upload delete requests table only when there are updates since…
Browse files Browse the repository at this point in the history
… last upload (#16008)
  • Loading branch information
sandeepsukhani authored Jan 30, 2025
1 parent e3d1054 commit c99771e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/compactor/deletion/delete_requests_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ func (d *DeleteRequestsManager) mergeShardedRequests(ctx context.Context) error
continue
}

level.Info(util_log.Logger).Log("msg", "merging sharded request",
"request_id", req.RequestID,
"num_shards", len(deletesPerRequest),
"start_time", req.StartTime.Unix(),
"end_time", req.EndTime.Unix(),
)
if err := d.deleteRequestsStore.MergeShardedRequests(ctx, req, deletesPerRequest[req.RequestID]); err != nil {
return err
}
Expand Down
14 changes: 13 additions & 1 deletion pkg/compactor/deletion/delete_requests_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
type deleteRequestsTable struct {
indexStorageClient storage.Client
dbPath string
updatedAt time.Time
uploadedAt time.Time

boltdbIndexClient *local.BoltIndexClient
db *bbolt.DB
Expand Down Expand Up @@ -98,6 +100,10 @@ func (t *deleteRequestsTable) loop() {
}

func (t *deleteRequestsTable) uploadFile() error {
if t.uploadedAt.After(t.updatedAt) {
level.Debug(util_log.Logger).Log("msg", "skipping uploading delete requests db since there have been no updates to the table since last upload")
return nil
}
level.Debug(util_log.Logger).Log("msg", "uploading delete requests db")

tempFilePath := fmt.Sprintf("%s.%s", t.dbPath, tempFileSuffix)
Expand Down Expand Up @@ -144,7 +150,12 @@ func (t *deleteRequestsTable) uploadFile() error {
return err
}

return t.indexStorageClient.PutFile(context.Background(), DeleteRequestsTableName, deleteRequestsIndexFileName, f)
if err := t.indexStorageClient.PutFile(context.Background(), DeleteRequestsTableName, deleteRequestsIndexFileName, f); err != nil {
return err
}

t.uploadedAt = time.Now()
return nil
}

func (t *deleteRequestsTable) Stop() {
Expand Down Expand Up @@ -178,6 +189,7 @@ func (t *deleteRequestsTable) BatchWrite(ctx context.Context, batch index.WriteB
}
}

t.updatedAt = time.Now()
return nil
}

Expand Down

0 comments on commit c99771e

Please sign in to comment.