Repository navigation
Keep CA journal in-memory state after datastore save failures - #6964
Merged
Merged
Conversation
Journal save failures are treated as non-fatal by the CA manager. The manager logs the error and continues using the newly prepared or activated authority/key, so rolling back only the in-memory journal leaves it behind the manager's live slot state. That rollback also does not make the operation crash-consistent. If the datastore save failed, the persisted journal is already stale; reverting the in-memory copy only prevents a later successful journal save from catching up to the state the manager is actually using. Leave journal mutations in memory when persistence fails, and continue to return the save error so callers can log it. This keeps the journal aligned with the running manager and lets subsequent successful saves persist the latest known state. Signed-off-by: Carlo Teubner <[email protected]>
Signed-off-by: Carlo Teubner <[email protected]>
Signed-off-by: Carlo Teubner <[email protected]>
c4rlo
marked this pull request as ready for review
May 17, 2026 14:30
c4rlo
requested review from
MarcosDY,
amartinezfayo,
evan2645,
rturner3 and
sorindumitru
as code owners
May 17, 2026 14:30
amartinezfayo
approved these changes
May 19, 2026
amartinezfayo
left a comment
Member
There was a problem hiding this comment.
Thank you so much @c4rlo for this fix! Great cleanup also.
MikeZappa87
pushed a commit
to MikeZappa87/spire
that referenced
this pull request
May 29, 2026
…#6964) * Keep journal state on save failure Journal save failures are treated as non-fatal by the CA manager. The manager logs the error and continues using the newly prepared or activated authority/key, so rolling back only the in-memory journal leaves it behind the manager's live slot state. That rollback also does not make the operation crash-consistent. If the datastore save failed, the persisted journal is already stale; reverting the in-memory copy only prevents a later successful journal save from catching up to the state the manager is actually using. Leave journal mutations in memory when persistence fails, and continue to return the save error so callers can log it. This keeps the journal aligned with the running manager and lets subsequent successful saves persist the latest known state. Signed-off-by: Carlo Teubner <[email protected]> * Simplify journal cap trimming Signed-off-by: Carlo Teubner <[email protected]> * Refresh journal docs and WIT test coverage Signed-off-by: Carlo Teubner <[email protected]> --------- Signed-off-by: Carlo Teubner <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Callers of journal mutation methods (i.e. CA managers) treat journal save failures as non-fatal: they log the error and continue using the newly prepared or activated authority/key. Rolling back only the in-memory journal makes it diverge from the manager’s live slot state, and it does not fix the already-stale persisted journal.
Therefore, stop rolling back in-memory journal mutations when datastore saves fail. Keeping the in-memory journal advanced lets a later successful save persist the latest known manager state.
The previous rollback logic was actually flawed even on its own terms: the
backupvalue used was only a reference, not its own independent copy. We also weren't restoring theAuthorityIdfield inUpdateJWTKeyStatusetc.Also:
slices.Clone