Skip to content

GO-7561 nodespace: retry creating the space's consensus log - #251

Merged
requilence merged 3 commits into
mainfrom
go-7561-addlog-retry
Oct 7, 2026
Merged

requilence merged 3 commits into
mainfrom
go-7561-addlog-retry

Conversation

@requilence

@requilence requilence commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

nodeSpace.Init creates the space's consensus log with AddLog and then watches it. Every node that stores the space does this, usually at the same time. A failed AddLog was only logged, and the watch that followed could miss a log that another node had not committed yet, leaving the node without ACL pushes for that space. The warning also did not name the space.

Fix

addLog retries a failed AddLog up to 3 times (100 ms, then 200 ms) until the log is created or found existing. Forbidden and InvalidPayload are not retried, and a done context stops the retries. A failure is still only logged, so the space loads; the warning now has the space id.

Tests

  • TestNodeSpace_addLog: success, existing log, retry until the log exists, exhaustion, permanent error, cancelled context.
  • TestNodeSpace_Init: AddLog is retried before Watch; the space still loads when every attempt fails.

Deploy

A safety net: with anyproto/any-sync-consensusnode#115 the consensus node itself retries the conflicting transaction, and the losing node gets ErrLogExists. This PR helps with older consensus nodes, if that retry is exhausted, or on a transport error. It does not re-watch: if every attempt fails, the watch still ends with ErrLogNotFound, as before. Works with old and new consensus nodes; no deploy order.

Part of GO-7561.

Every node that stores a space creates its consensus log when it loads the
space, usually at the same time as the others, and then watches it. A failed
AddLog was only logged, and the watch that followed could miss a log that
was not created yet.

A failed AddLog is now retried a few times until the log is created or found
existing; Forbidden and InvalidPayload are not retried. A failure is still
only logged, so the space loads, and the warning now names the space.
Covers Init itself, so the retry cannot be bypassed there, and drops a
wall-clock assertion from the cancellation test; the mock already checks the
single attempt.
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

New Coverage 52.0% of statements
Patch Coverage 100.0% of changed statements (20/20)

Coverage provided by https://github.com/seriousben/go-patch-cover-action

The spaceId parameter was always s.Id(); the tests now use a mock space.
@requilence
requilence merged commit 37f4b04 into main Oct 7, 2026
6 checks passed
@requilence
requilence deleted the go-7561-addlog-retry branch October 7, 2026 13:06
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants