Skip to content

control-connection fallback: treat empty session keyspace as unset #1037

Description

@dkropachev

Problem

Control-connection fallback treats an empty-string Session.keyspace as a real keyspace, while the rest of session setup treats it as unset.

SkipPoolCreation binds the shared control connection to the raw value:

if fallback_mode is ControlConnectionQueryFallback.SkipPoolCreation:
control_connection = self.cluster.control_connection
conflict = control_connection._attach_application_session(self.keyspace, self)
if conflict is not None:
raise InvalidRequest(conflict)

The on-demand fallback path does the same, then attempts to select any keyspace that is not None:

keyspace = self.session.keyspace
new_application_session = \
self.session not in control_connection._application_sessions
conflict = control_connection._attach_application_session(keyspace, self.session)
if conflict is not None:
self._set_final_exception(InvalidRequest(conflict))
return _NOT_SET

if keyspace is not None and connection.keyspace != keyspace:
return self._set_control_connection_keyspace(
connection, host, keyspace, message=message, cb=cb,
request_id=request_id,
provisional_session=provisional_session)

A session created with keyspace='' can therefore conflict with an otherwise equivalent no-keyspace session and can issue USE "" through fallback.

Expected behavior

Normalize a falsey session keyspace to None before control-connection binding and dispatch. Sessions using '' and None should share the no-keyspace binding, and fallback should send the original query without an empty USE request.

Acceptance criteria

  • Fallback treats keyspace='' as no keyspace.
  • SkipPoolCreation treats keyspace='' as no keyspace.
  • Empty-string and None sessions do not conflict solely because of their representation.
  • No USE "" request is sent.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions