chore: upload delete requests table only when there are updates since last upload (#16008)

pull/16013/head
Sandeep Sukhani 4 months ago committed by GitHub
parent e3d10542fd
commit c99771efb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      pkg/compactor/deletion/delete_requests_manager.go
  2. 14
      pkg/compactor/deletion/delete_requests_table.go

@ -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
}

@ -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
@ -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)
@ -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() {
@ -178,6 +189,7 @@ func (t *deleteRequestsTable) BatchWrite(ctx context.Context, batch index.WriteB
}
}
t.updatedAt = time.Now()
return nil
}

Loading…
Cancel
Save