From 76350bd01072921484303a16e9879f69d907f6f3 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Tue, 15 Oct 2024 19:57:51 -0400 Subject: [PATCH] Make progress logging more intelligent/dynamic Signed-off-by: Matt Lord --- go/vt/vttablet/tabletmanager/rpc_vreplication.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/go/vt/vttablet/tabletmanager/rpc_vreplication.go b/go/vt/vttablet/tabletmanager/rpc_vreplication.go index cdd83640553..8ddf1391ac4 100644 --- a/go/vt/vttablet/tabletmanager/rpc_vreplication.go +++ b/go/vt/vttablet/tabletmanager/rpc_vreplication.go @@ -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 { @@ -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) }