Skip to content

CASSJAVA-142: MetadataManager: schema refresh never runs again after one refresh fails with "Control channel not available" - #2102

Open
QFREEE wants to merge 3 commits into
apache:trunkfrom
QFREEE:CASSJAVA-142
Open

QFREEE wants to merge 3 commits into
apache:trunkfrom
QFREEE:CASSJAVA-142

Conversation

@QFREEE

@QFREEE QFREEE commented Oct 13, 2026

Copy link
Copy Markdown

https://issues.apache.org/jira/browse/CASSJAVA-142

When a schema refresh fails in schemaQueriesFactory.newInstance() or in the schema agreement step, MetadataManager fails the caller's future but leaves currentSchemaRefresh set. Every later refresh is queued and never starts, so schema metadata freezes and later DDL requests time out until the session closes. CASSJAVA-13 (formerly CASSANDRA-19468, commit 6c48329, 4.18.1) fixed the first caller; this fixes every caller after it.

Changes:

  • Add finishSchemaRequest(), which clears currentSchemaRefresh and starts the queued refresh.
  • Submit it to the admin executor from all three completion paths: the agreementError branch, the newInstance() catch block, and the existing success callback.
  • The success callback changes too: when execute() fails, thenApplyAsync(..., adminExecutor) passes the failure through on the control connection's event loop, so the old inline cleanup ran off the admin thread and the queued refresh was lost.

Behavior change: after an early failure, later DDL requests no longer time out. While the control connection is down, each one completes with schema agreement false and the existing WARN, as the first one already did.

Tests (MetadataManagerTest), one per completion path:

  • should_run_queued_request_after_schema_queries_factory_throws
  • should_run_next_request_after_schema_agreement_fails
  • should_run_queued_request_after_schema_queries_fail

All three fail on trunk and pass with the fix. Full core unit suite passes. Verified end to end against a real Cassandra 5.0 node (details in the JIRA).

…ne refresh fails with "Control channel not available"

When a schema refresh failed in schemaQueriesFactory.newInstance() or in the
schema agreement step, the caller's future failed but currentSchemaRefresh
stayed set, so every later refresh was queued forever.

Add finishSchemaRequest(), which clears currentSchemaRefresh and starts the
queued refresh, and submit it to the admin executor from all three
completion paths. This also covers a failed execute(): its callback runs on
the control connection's event loop, where the old inline cleanup broke the
admin-thread confinement and lost the queued refresh.

Generated-by: Claude Opus 5.5 (1M context)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the schema-refresh cleanup change.

No open issues 🎉

What changed in this PR

Fixes CASSJAVA-142 so a failed schema refresh does not block subsequent refreshes in the driver’s metadata manager.

Changes:

  • Centralizes cleanup to clear the active refresh and start any queued request.
  • Schedules cleanup on the admin executor across all three completion paths.
  • Adds regression tests for query-factory, schema-agreement, and query-execution failures.
File Description
core/​src/​test/​java/​com/​datastax/​oss/​driver/​internal/​core/​metadata/​MetadataManagerTest.java Adds three regression tests verifying refreshes continue after failures.
core/​src/​main/​java/​com/​datastax/​oss/​driver/​internal/​core/​metadata/​MetadataManager.java Adds shared refresh cleanup and schedules it on the admin executor.

Review effort: Balanced

@SiyaoIsHiding SiyaoIsHiding left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Took me a very long time to understand what's happening. Looks good to me! Thank you for the great fix and well-written PR and JIRA ticket!

This branch has not been deployed

No deployments
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.

3 participants