Skip to content

fix: prevent schema refresh deadlock when newInstance() fails#842

Merged
dkropachev merged 1 commit intoscylladb:scylla-4.xfrom
dkropachev:fix/schema-refresh-deadlock-on-newinstance-failure
Mar 19, 2026
Merged

fix: prevent schema refresh deadlock when newInstance() fails#842
dkropachev merged 1 commit intoscylladb:scylla-4.xfrom
dkropachev:fix/schema-refresh-deadlock-on-newinstance-failure

Conversation

@dkropachev
Copy link
Copy Markdown

@dkropachev dkropachev commented Mar 19, 2026

Summary

  • When SchemaQueries.newInstance() throws or schema agreement check fails in startSchemaRequest(), currentSchemaRefresh was never reset to null, permanently blocking all future schema refreshes for the session
  • Extracted cleanup logic into onSchemaRefreshComplete() helper and call it from all three completion paths (agreement error, newInstance() exception, normal completion)
  • Added tests verifying recovery after newInstance() failure, agreement error, and queued refresh draining

Fixes #841

Test plan

  • MetadataManagerTest.refreshSchema_should_recover_after_newInstance_failure — second refresh completes after first fails
  • MetadataManagerTest.refreshSchema_should_recover_after_agreement_error — second refresh completes after agreement check failure
  • MetadataManagerTest.refreshSchema_should_drain_queued_refresh_after_newInstance_failure — queued refresh is drained when active refresh fails
  • All existing MetadataManagerTest tests pass

…check fails

When SchemaQueries.newInstance() throws or schema agreement check fails,
the cleanup code (resetting currentSchemaRefresh, completing
firstSchemaRefreshFuture, draining queuedSchemaRefresh) was never
executed, permanently blocking all future schema refreshes for the
session.

Extract cleanup into onSchemaRefreshComplete() and call it from all
three completion paths: agreement error, newInstance() exception, and
normal completion.

Fixes: scylladb#841
@dkropachev dkropachev force-pushed the fix/schema-refresh-deadlock-on-newinstance-failure branch from 175fd3e to 4779c0e Compare March 19, 2026 15:01
@dkropachev dkropachev requested a review from nikagra March 19, 2026 15:12
@dkropachev dkropachev marked this pull request as ready for review March 19, 2026 15:43
Copy link
Copy Markdown

@nikagra nikagra left a comment

Choose a reason for hiding this comment

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

👍

@dkropachev dkropachev merged commit e30a07d into scylladb:scylla-4.x Mar 19, 2026
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schema refresh permanently blocked when SchemaQueries.newInstance() throws

2 participants