Skip to content

Commit

Permalink
Make progress logging more intelligent/dynamic
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Oct 15, 2024
1 parent 76131b8 commit 76350bd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions go/vt/vttablet/tabletmanager/rpc_vreplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ func (tm *TabletManager) DeleteTableData(ctx context.Context, req *tabletmanager
batchSize = movetables.DefaultDeleteBatchSize
}
limit := &sqlparser.Limit{Rowcount: sqlparser.NewIntLiteral(fmt.Sprintf("%d", batchSize))}
// We will log some progress info every 100 delete batches.
progressRows := uint64(batchSize * 100)

throttledLogger := logutil.NewThrottledLogger("DeleteTableData", 1*time.Minute)
checkIfCanceled := func() error {
Expand Down Expand Up @@ -214,10 +216,10 @@ func (tm *TabletManager) DeleteTableData(ctx context.Context, req *tabletmanager
query, err)
}
rowsDeleted += res.RowsAffected
// Log some progress info periodically to give the operator some idea of how much
// work we've done, how much is left, and how long it may take (considering
// throttling, system performance, etc).
if rowsDeleted%1e5 == 0 {
// Log some progress info periodically to give the operator some idea of
// how much work we've done, how much is left, and how long it may take
// (considering throttling, system performance, etc).
if rowsDeleted%progressRows == 0 {
log.Infof("Successfully deleted %d rows of data from table %s so far, using query %q",
rowsDeleted, table, query)
}
Expand Down

0 comments on commit 76350bd

Please sign in to comment.