Skip to content

De-flake testIdpUpdate: atomic issuer deletion in Cassandra batch#5316

Open
blackheaven wants to merge 3 commits into
developfrom
gdifolco/fix-flaky-tests-spar-idp-update
Open

De-flake testIdpUpdate: atomic issuer deletion in Cassandra batch#5316
blackheaven wants to merge 3 commits into
developfrom
gdifolco/fix-flaky-tests-spar-idp-update

Conversation

@blackheaven

Copy link
Copy Markdown
Contributor

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

The flaky testIdpUpdate test failed intermittently with HTTP 400 where
200 was expected. Root cause: the IdP update in idpUpdateXML performed
the issuer index deletion as a separate Cassandra write after the
config insertion batch. When an issuer was reused across updates
(e.g., A -> B -> A), the tombstone from the first deletion could
shadow the later insert due to clock skew between Cassandra
coordinators, causing the finalize-login endpoint to fail its
issuer-based IdP lookup.

Server fix: move old-issuer deletion into the same logged batch as
insertIdPConfig, so insert and delete share the same batch timestamp.

Test fix: add status checks on updateIdp calls and wrap post-update
logins with 'eventually' for resilience against residual consistency
delays.
@blackheaven blackheaven requested review from a team as code owners July 3, 2026 21:33
@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Jul 3, 2026
Comment on lines +111 to +119
-- Delete old issuer mappings atomically with the new config insertion to
-- prevent Cassandra tombstone shadowing when an issuer is reused across
-- multiple updates (e.g., updating from issuer A to B and back to A).
forM_ oldIssuers $ \oldIssuer ->
case thisVersion of
WireIdPAPIV2 -> addPrepQuery delOldIssuerV2 (oldIssuer, tid)
WireIdPAPIV1 -> do
addPrepQuery delOldIssuerV1 (Identity oldIssuer)
addPrepQuery delOldIssuerV1' (Identity oldIssuer)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all callers of this function were deleting old configs, maybe we should parameterize this.

Address PR review feedback: not all callers of insertConfig were
previously deleting old issuer mappings. Moving the deletion
unconditionally into the batch changed behavior for idpCreate and
storeIdPConfig.

Introduce InsertMode (InsertOnly | InsertWithIssuerCleanup) so only
idpUpdateXML opts into atomic issuer cleanup, preserving the original
behavior of all other callers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants