Add LastValidBlockTimestamp to BlockUndoSignal#754
Conversation
Agent-Logs-Url: https://github.com/streamingfast/substreams/sessions/946c1b7d-643c-49d1-8107-94d423ec869a Co-authored-by: maoueh <123014+maoueh@users.noreply.github.com>
Agent-Logs-Url: https://github.com/streamingfast/substreams/sessions/946c1b7d-643c-49d1-8107-94d423ec869a Co-authored-by: maoueh <123014+maoueh@users.noreply.github.com>
| targetClock := blockRefToPB(reorgJunctionBlock) | ||
| lastValidBlockTimestamp := p.reversibleBlockTimestamps[reorgJunctionBlock.ID()] | ||
| if lastValidBlockTimestamp == nil { | ||
| reqctx.Logger(p.ctx).Debug("no timestamp found for reorg junction block, last_valid_block_timestamp will be unset in undo signal", zap.Stringer("reorg_junction_block", reorgJunctionBlock)) |
There was a problem hiding this comment.
Seems like a valid warning here instead of a "silent" debug.
| if clock.Timestamp != nil { | ||
| p.reversibleBlockTimestamps[clock.Id] = clock.Timestamp | ||
| } |
There was a problem hiding this comment.
Done in e6c862e — removed the nil guard in both handleStepPartial and handleStepNew. Also updated the lookup to use the ok idiom so storing a nil timestamp (block with no timestamp) doesn't falsely trigger the warning; the warning now only fires when the block ID was never tracked at all.
…diom for missing entry Agent-Logs-Url: https://github.com/streamingfast/substreams/sessions/d82a5fdd-2db3-4ee7-8413-d2f5a11eaec4 Co-authored-by: maoueh <123014+maoueh@users.noreply.github.com>
Completed the reference analysis — no leaks found. Here's a summary: Entries are added in two places:
Every entry is removed by exactly one of three cleanup paths:
Additional notes:
|
|
This is very dangerous because there are cases where we have not seen the blocks and would send an UNDO signal with last_valid_block_timestamp=0 (ex: when resolving a cursor from oneblock files in bstream) |
last_valid_block_timestampfield toBlockUndoSignalin v2 protoreversibleBlockTimestampsmap to Pipeline struct for tracking block timestampshandleStepNewto always store clock timestamps (remove nil guard, only skip for final blocks)handleStepPartial(isLast) to always store clock timestamps (remove nil guard)handleStepFinalto clean up timestamps when blocks become irreversiblehandleStepStalledto clean up timestampshandleUndoto clean up the undone block's timestamp and populateLastValidBlockTimestampin the undo signalokidiom (found) to distinguish "block never tracked" from "block tracked with nil timestamp", avoiding false warningsDebugtoWarnhandleStepNewandhandleStepPartialare cleaned up byhandleStepFinal,handleStepStalled, orhandleUndo— no leaks foundOriginal prompt