Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion storage/posix/antispam/badger.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@ func (f *follower) Follow(ctx context.Context, lr tessera.LogReader) {
if err != errOutOfSync {
slog.ErrorContext(ctx, "Failed to commit antispam population tx", slog.Any("error", err))
}
stop()
if stop != nil {
stop()
}
next = nil
continue
}
Expand Down
38 changes: 38 additions & 0 deletions storage/posix/antispam/badger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,44 @@ func TestAntispamPushbackRecovers(t *testing.T) {
}
}

func TestAntispamFollowerErrorBeforeStream(t *testing.T) {
as, err := NewAntispam(t.Context(), t.TempDir(), AntispamOpts{})
if err != nil {
t.Fatalf("NewAntispam: %v", err)
}

fl, shutdown := testonly.NewTestLog(t, tessera.NewAppendOptions().WithCheckpointInterval(time.Second))
defer func() {
if err := shutdown(t.Context()); err != nil {
t.Logf("shutdown: %v", err)
}
}()

f := as.Follower(testBundleHasher)

mockLR := &failingLogReader{
LogReader: fl.LogReader,
}

ctx, cancel := context.WithCancel(t.Context())
defer cancel()

go f.Follow(ctx, mockLR)

// Wait for the ticker (1s) and some execution time.
time.Sleep(1500 * time.Millisecond)

cancel()
}

type failingLogReader struct {
tessera.LogReader
}

func (f *failingLogReader) IntegratedSize(ctx context.Context) (uint64, error) {
return 0, fmt.Errorf("injected error")
}

func testIDHash(d []byte) []byte {
r := sha256.Sum256(d)
return r[:]
Expand Down
Loading