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
Problem
Control-connection fallback treats an empty-string
Session.keyspaceas a real keyspace, while the rest of session setup treats it as unset.SkipPoolCreationbinds the shared control connection to the raw value:python-driver/cassandra/cluster.py
Lines 2894 to 2898 in 5651509
The on-demand fallback path does the same, then attempts to select any keyspace that is not
None:python-driver/cassandra/cluster.py
Lines 5735 to 5741 in 5651509
python-driver/cassandra/cluster.py
Lines 5766 to 5770 in 5651509
A session created with
keyspace=''can therefore conflict with an otherwise equivalent no-keyspace session and can issueUSE ""through fallback.Expected behavior
Normalize a falsey session keyspace to
Nonebefore control-connection binding and dispatch. Sessions using''andNoneshould share the no-keyspace binding, and fallback should send the original query without an emptyUSErequest.Acceptance criteria
Fallbacktreatskeyspace=''as no keyspace.SkipPoolCreationtreatskeyspace=''as no keyspace.Nonesessions do not conflict solely because of their representation.USE ""request is sent.Related