mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
transport: RecoverySink — review-feedback doc tightening
Three doc-only follow-ups from architect code review of 845c810
(non-blocking; no logic changes):
1. NewRecoverySink — explicit caller obligations:
- Defer EndSession at the StartSession call site so a
StartSession error path still restores steady context
(recovery.Sender.Run already does this; production callers
using NewRecoverySink directly must too).
- nil sessionConn = programmer error (Realtime emits would have
nowhere to go). nil steadyConn = honest only when no steady
ship was in flight; next steady emit fails closed at EmitFunc.
2. installRecordingShipper (test helper) — TEST-ONLY /
single-goroutine note. The entry.shipper assignment bypasses
walShipperMu deliberately; production paths take that mutex.
Don't lift the pattern into production or concurrent tests
without re-introducing the lock.
Test suite unchanged; go test ./core/transport/ -run TestRecoverySink
still PASS (6/6).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
845c81071d
commit
bb36a601b8
2 files changed
+21
No files matched your search
@@ -61,6 +61,20 @@ type RecoverySink struct {
|
||||
// NewRecoverySink ensures the WalShipperEntry exists (via
|
||||
// WalShipperFor) so the emit-context update in StartSession has
|
||||
// somewhere to land.
|
||||
//
|
||||
// Caller obligations:
|
||||
//
|
||||
// - Defer EndSession at the call site that calls StartSession.
|
||||
// If StartSession returns an error, the emit context has already
|
||||
// been swapped to session — only the deferred EndSession restores
|
||||
// steady. (recovery.Sender.Run defers sink.EndSession; production
|
||||
// callers using NewRecoverySink directly must do the same.)
|
||||
// - The caller is responsible for snapshotting the steady context
|
||||
// correctly. Passing nil sessionConn is a programmer error
|
||||
// (Realtime emits during the session would have nowhere to go);
|
||||
// passing nil steadyConn is honest only when no steady ship was
|
||||
// in flight before this session — the next steady emit will see
|
||||
// "no conn" and fail closed at the EmitFunc level.
|
||||
func NewRecoverySink(
|
||||
e *BlockExecutor,
|
||||
replicaID string,
|
||||
|
||||
@@ -49,6 +49,13 @@ type recordedEmit struct {
|
||||
//
|
||||
// Returns a pointer to a slice the test consumes; callers must
|
||||
// hold the test's mutex while reading.
|
||||
//
|
||||
// TEST-ONLY / single-goroutine: the entry.shipper assignment below
|
||||
// does NOT acquire walShipperMu. Production paths (WalShipperFor,
|
||||
// updateWalShipperEmitContext) take that mutex; this helper bypasses
|
||||
// it deliberately because tests run before any concurrent access.
|
||||
// Do not lift this pattern into production code or concurrent test
|
||||
// scenarios without re-introducing the lock.
|
||||
func installRecordingShipper(t *testing.T, e *BlockExecutor, replicaID string) (*[]recordedEmit, *sync.Mutex) {
|
||||
t.Helper()
|
||||
|
||||
|
||||
Reference in new issue
Block a user