Skip to content

[r3.6] db/kv/membatchwithdb: surface DomainReader read errors instead of swallowing them - #22960

Merged
AskAlexSharov merged 3 commits into
release/3.6from
lupin012/backport_domain_reader_errors_36
Aug 4, 2026
Merged

[r3.6] db/kv/membatchwithdb: surface DomainReader read errors instead of swallowing them#22960
AskAlexSharov merged 3 commits into
release/3.6from
lupin012/backport_domain_reader_errors_36

Conversation

@lupin012

@lupin012 lupin012 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Cherry-pick of #22893 to release/3.6.

#22511 routed receipt-domain reads through the overlay DomainReader and is already on this branch. #22893 is its follow-up: the code #22511 added gated the DomainReader result on err == nil && ok, so a reader error fell through to the committed tx and silently reopened the same stale-read window. All four sites still have the old gating here:

db/kv/membatchwithdb/memory_mutation.go:956   MemoryMutation.GetAsOf
db/kv/membatchwithdb/memory_mutation.go:989   MemoryMutation.HistorySeek
db/kv/membatchwithdb/memory_mutation.go:1155  OverlayTemporalReadView.GetAsOf
db/kv/membatchwithdb/memory_mutation.go:1174  OverlayTemporalReadView.HistorySeek

Worth landing before GA: shipping #22511 without #22893 is the one combination where the fix looks complete but the error path is not.

The same pair is being backported to release/3.5 in #22951, where #22511 is missing too.

Tests

The tests are committed below the fix, so the history shows the cycle — check out 19feda4356 to see red, HEAD to see green.

  • TestDomainReadErrorsPropagate — new. Fails without the fix (Expected error ... but got nil, both subtests), passes with it. Covers MemoryMutation and OverlayTemporalReadView.
  • TestReceiptAsOf_InFlightBlockLogIndex — passes already, since db/state: route receipt domain GetAsOf/HistorySeek through overlay DomainReader #22511 is here. Adds coverage of the production key (LogIndexAfterTxKey) and accessor (rawtemporaldb.ReceiptAsOf), which the storage-level test shipped with db/state: route receipt domain GetAsOf/HistorySeek through overlay DomainReader #22511 does not touch.
  • TestGetReceiptLogIndexThroughOverlay — passes already. Pins the production wiring: the overlay is seeded with a log index the committed tx does not hold, so only a read routed through Filters.WithTemporalOverlay can produce it. Drop that call from GetReceipt and this test fails — nothing else in the tree catches it.

No conflicts in either cherry-pick; the APIs on 3.6 match what the tests were written against.

Context

Both fixes address wrong logIndex values served for a block whose commit is in flight — reported on #22106. The values are never persisted, so no resync or DB rewind is involved.

lupin012 and others added 2 commits August 3, 2026 08:15
Three tests for the overlay receipt-read path, none of which exists on this
branch today:

- TestDomainReadErrorsPropagate — a DomainReader error must reach the caller
  instead of falling through to the committed tx. Fails on release/3.6 as it
  stands: #22893 is not here, so the error is swallowed and the read silently
  answers with stale data. Covers both MemoryMutation and
  OverlayTemporalReadView.

- TestReceiptAsOf_InFlightBlockLogIndex — ReceiptAsOf through the overlay read
  view must return the in-flight block's LogIndexAfterTx. Passes already
  (#22511 is here); adds coverage of the production key and accessor, which the
  storage-level test shipped with #22511 does not touch.

- TestGetReceiptLogIndexThroughOverlay — pins the production wiring: the
  overlay is seeded with a log index the committed tx does not hold, so only a
  read routed through Filters.WithTemporalOverlay can produce it. Drop that
  call from GetReceipt and this test fails; nothing else in the tree does.
…llowing them (#22893)

Independent correctness fix split out of #21414 (per the request to
break it up). Stands alone on `main`.

`MemoryMutation` and `OverlayTemporalReadView` `GetAsOf`/`HistorySeek`
gated the `DomainReader` result with `err == nil && ok`, so a reader
error fell through to the committed tx and was silently hidden. This
propagates the error and keeps the `ok`-based committed fallback (a
tombstone is `ok=true`, so it is not resurrected).

No dependency on the background-commit work; part of the split recorded
on #21414.

(cherry picked from commit 8324709)
@AskAlexSharov
AskAlexSharov requested a review from mh0lt August 3, 2026 09:16
@yperbasis yperbasis added this to the 3.6.0 milestone Aug 3, 2026
pull Bot pushed a commit to Dustin4444/erigon that referenced this pull request Aug 3, 2026
…erlay (erigontech#22961)

Port of the tests added in the release-branch backports erigontech#22951
(`release/3.5`) and erigontech#22960 (`release/3.6`).

All three pass on `main` — both erigontech#22511 and erigontech#22893 are here — so they
land as regression coverage. Each was written against the branch where
its fix was missing and verified red there first:

| Test | Verified red on | Without |
|---|---|---|
| `TestReceiptAsOf_InFlightBlockLogIndex` | `release/3.5` | erigontech#22511 —
returns `0x7` instead of `0x3` |
| `TestDomainReadErrorsPropagate` | `release/3.6` | erigontech#22893 — error
swallowed, `but got nil` |
| `TestGetReceiptLogIndexThroughOverlay` | `main` | the
`WithTemporalOverlay` call in `GetReceipt` |

The third one is the reason this is worth having on `main` regardless of
the backports: `Filters.WithOverlay` / `WithTemporalOverlay` had **no
test coverage anywhere in the tree**. Remove `tx =
g.filters.WithTemporalOverlay(tx)` from `GetReceipt` and the bug
reported on erigontech#22106 returns in production while CI stays green —
verified, that test now fails.

The other two also add coverage the upstream fixes did not ship:
erigontech#22511's own test works at storage level with a synthetic key, so
nothing exercised `LogIndexAfterTxKey` through
`rawtemporaldb.ReceiptAsOf`; erigontech#22893 shipped with no test at all.

One adaptation from the release branches: `AppendReceipt` is named
`AppendReceiptMetadata` here.
@lupin012
lupin012 marked this pull request as ready for review August 3, 2026 19:38
@lupin012
lupin012 requested a review from sudeepdino008 as a code owner August 3, 2026 19:38
@AskAlexSharov
AskAlexSharov added this pull request to the merge queue Aug 4, 2026
Merged via the queue into release/3.6 with commit 27e4fdb Aug 4, 2026
94 checks passed
@AskAlexSharov
AskAlexSharov deleted the lupin012/backport_domain_reader_errors_36 branch August 4, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants