Skip to content

Schema refresh permanently blocked when SchemaQueries.newInstance() throws #841

@dkropachev

Description

@dkropachev

Description

In MetadataManager.SingleThreaded.startSchemaRequest(), when schemaQueriesFactory.newInstance() throws a synchronous exception (e.g., control channel unavailable or control node not found in metadata), the currentSchemaRefresh field is never reset to null, and the queued schema refresh is never drained.

This causes all future schema refreshes to be permanently blocked for the lifetime of the session.

Root cause

The cleanup code that resets currentSchemaRefresh, completes firstSchemaRefreshFuture, and drains queuedSchemaRefresh only runs inside the .whenComplete() callback of the thenApplyAsync chain. When newInstance() throws synchronously before that chain is even constructed, the catch (Throwable t) block only completes the refreshFuture exceptionally but skips all cleanup.

The same issue exists when agreementError != nullcurrentSchemaRefresh is never cleared there either.

Impact

  • currentSchemaRefresh remains non-null forever — all subsequent schema refresh requests are queued and never executed
  • firstSchemaRefreshFuture may never complete
  • The queued refresh (queuedSchemaRefresh) is stuck forever
  • This is a permanent deadlock of the schema refresh mechanism for the session

How to trigger

DefaultSchemaQueriesFactory.newInstance() can throw IllegalStateException when:

  • The control channel is null or already closed
  • The control node's endpoint is not found in metadata

These are transient conditions (e.g., a node going down during schema refresh) that should be recoverable, but due to this bug they permanently break schema refresh.

Fix

Add cleanup logic (reset currentSchemaRefresh, complete firstSchemaRefreshFuture, drain queuedSchemaRefresh) to both:

  1. The catch (Throwable t) block handling newInstance() failures
  2. The agreementError != null branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions