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.
This commit is contained in:
phatlc authored and Nick Craig-Wood committed 2026-10-13 12:10:00 +01:00
1 parent 927b6afd04
commit 102ef16e4b
3 files changed
+31

No files matched your search

+1
View File
@@ -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
+1
View File
@@ -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")
})
}
+29
View File
@@ -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())
}