Skip to content

Compact block and requested block race to archival. #1268

Closed

Description

@evoskuil

#1266

Resolution requires a single claim on the block, which means it needs to flow through the tx chaser.

Activity

  1. added this to the 4.0 milestone on Nov 18, 2026
  2. added theissue type on Nov 18, 2026
  3. evoskuil commented on Nov 18, 2026

    @evoskuil
    MemberAuthor

    A block can be associated by the compact block path and the full block path at once, storing its txs twice. The duplicate tx records break get_tx_position, so address history and unspent fail for the affected addresses.

    The two paths check and write on different strands:

    • chaser_transaction::do_submit_compact checks is_associated(link) and stores, on the transaction chaser's strand.
    • protocol_block_in_31800::handle_receive_block stores on the strand of the channel that downloaded the block. Skip a requested block that is already associated. #1266 adds an is_associated(link) check here, which narrows the window but does not close it: both paths can pass the check before either writes.

    The database cannot catch this later. set_txs runs after the tx records are written, and the transactor is shared by both writers.

    Resolution requires a single claim on the block, taken before any tx is written, owned by the transaction chaser.

    The block write must remain on the thread of the channel that received the block. The block is allocated on that thread, so posting it to the chaser (or any other strand) to write would move its deallocation to another thread, which is costly. The claim therefore cannot be a post; it must be a synchronous atomic latch:

    • The chaser exposes an atomic latch on the header link, callable from any thread (one test-and-set).
    • handle_receive_block claims before set_code. The winner writes on its own channel thread, as now. The loser drops its copy and clears its request.
    • do_submit_compact claims the same latch before filling, returning duplicate_block if it loses.
    • A failed write releases its claim so another copy can store the block.

    The is_associated early-out can remain as a cheap shortcut; the latch is what guarantees a single writer.

  4. evoskuil commented on Nov 18, 2026

    @evoskuil
    MemberAuthor

    Patched here, please confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions