From 102ef16e4b40aaab56e2b19df00e7ad36cdc7ad5 Mon Sep 17 00:00:00 2001 From: phatlc Date: Sat, 19 Sep 2026 21:04:00 +0700 Subject: [PATCH] lib/batcher: log when committing uploads has finished - fixes #5564 On shutdown the batcher logged "Committing uploads - please wait..." but nothing once the commit had completed, so the log looked as if rclone had stopped part way through. Log "Committing uploads - done" when the pending batches have been committed. This affects the backends which use the batcher, dropbox and googlephotos. --- cmd/bisync/bisync_test.go | 1 + lib/batcher/batcher.go | 1 + lib/batcher/batcher_test.go | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/cmd/bisync/bisync_test.go b/cmd/bisync/bisync_test.go index 8e6999d6c..437b3af77 100644 --- a/cmd/bisync/bisync_test.go +++ b/cmd/bisync/bisync_test.go @@ -91,6 +91,7 @@ var logReplacements = []string{ `^NOTICE: too_many_(requests|write_operations)/\.*: Too many requests or write operations.*$`, dropMe, `^NOTICE: .*?: Forced to upload files to set modification times on this backend.$`, dropMe, `^INFO : .*? Committing uploads - please wait...$`, dropMe, + `^INFO : .*? Committing uploads - done$`, dropMe, `^INFO : .*?: src and dst identical but can't set mod time without deleting and re-uploading$`, dropMe, `^INFO : .*?: src and dst identical but can't set mod time without re-uploading$`, dropMe, // ignore crypt info messages diff --git a/lib/batcher/batcher.go b/lib/batcher/batcher.go index ace41f952..3db60f5bc 100644 --- a/lib/batcher/batcher.go +++ b/lib/batcher/batcher.go @@ -251,6 +251,7 @@ func (b *Batcher[Item, Result]) Shutdown() { b.in <- request[Item, Result]{quit: true} b.admitMu.Unlock() b.wg.Wait() + fs.Infof(b.f, "Committing uploads - done") }) } diff --git a/lib/batcher/batcher_test.go b/lib/batcher/batcher_test.go index 72873f12c..9bdb98104 100644 --- a/lib/batcher/batcher_test.go +++ b/lib/batcher/batcher_test.go @@ -1,9 +1,11 @@ package batcher import ( + "bytes" "context" "errors" "fmt" + "log/slog" "sync" "sync/atomic" "testing" @@ -362,3 +364,30 @@ func TestBatcherCommitAsync(t *testing.T) { assert.Equal(t, int32(4), commits.Load()) assert.Equal(t, int32(10), totalSize.Load()) } + +func TestBatcherShutdownLog(t *testing.T) { + ctx := context.Background() + ci := fs.GetConfig(ctx) + oldLogLevel := ci.LogLevel + ci.LogLevel = fs.LogLevelDebug + defer func() { ci.LogLevel = oldLogLevel }() + var buf bytes.Buffer + fs.SetLogger(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelDebug})) + defer fs.SetLogger(slog.Default().Handler()) + + commitBatch := func(ctx context.Context, items []Item, results []Result, errors []error) error { + return nil + } + b, err := New[Item, Result](ctx, nil, commitBatch, Options{ + Mode: "async", + Size: 10, + Timeout: time.Hour, + MaxBatchSize: 1000, + }) + require.NoError(t, err) + _, err = b.Commit(ctx, "item", Item("item")) + require.NoError(t, err) + b.Shutdown() + + assert.Regexp(t, `(?s)Committing uploads - please wait\.\.\..*Committed async batch.*Committing uploads - done`, buf.String()) +}