[4/N] feat(submitqueue): activate request status materialization#343
[4/N] feat(submitqueue): activate request status materialization#343albertywu wants to merge 1 commit into
Conversation
Route synchronous, queued, and DLQ request-log writes through the shared materializer so authoritative and queue projections converge with retained history. Preserve the original DLQ failure reason as the terminal request last error. Validation: make fmt && make build && make test && make e2e-test
| if err := store.GetRequestLogStore().Insert(ctx, logEntry); err != nil { | ||
| return fmt.Errorf("failed to insert request log for %s: %w", requestID, err) | ||
| logEntry := entity.NewRequestLog(requestID, entity.RequestStatusError, logVersion, lastError, nil) | ||
| if err := requestcore.NewMaterializer(store).PersistLog(ctx, logEntry); err != nil { |
There was a problem hiding this comment.
This unconditional PersistLog(error) is now authoritative-status-bearing, and it runs even when the request is already in a different terminal state — with logVersion left at the request's current version on that branch. Conclude's landed log carries that same post-CAS version, so in logWins the two are versioned-terminal at equal RequestVersion and the decision falls to the timestamp tie-break — which this reconcile-time log always wins. Net effect: a request that landed (or cancelled) gets its user-visible Status/List state flipped to error whenever a stale message for it dead-letters afterward. failBatch amplifies it: an already-Succeeded batch still "fans out only" and flips every landed member. Before this PR the spurious error log was cosmetic history noise; now it overwrites the answer users see.
Fix shape: mirror conclude's divergent-terminal skip (conclude.go:128-140) — only write the error log when the terminal state is actually Error (i.e. this reconcile owns it, including the repair-on-redelivery case the comment above describes); a genuinely landed/cancelled request needs no error entry. The logWins tie-break on #342 is the belt to this suspender.
Summary
Route synchronous, queued, and DLQ request-log writes through the shared materializer so authoritative and queue projections converge with retained history.
Preserve the original DLQ failure reason as the terminal request last error.
Test Plan
✅
make fmt && make build && make test && make e2e-testStack