Page MenuHomeSoftware Heritage

Stop using `USE <keyspace>` with prepared statements
ClosedPublic

Authored by vlorentz on Thu, Aug 4, 1:55 PM.

Details

Summary

This caused the following warning:

WARNING  cassandra.protocol:libevreactor.py:361 Server warning: `USE <keyspace>` with prepared statements is considered to be an anti-pattern due to ambiguity in non-qualified table names. Please consider removing instances of `Session#setKeyspace(<keyspace>)`, `Session#execute("USE <keyspace>")` and `cluster.newSession(<keyspace>)` from your code, and always use fully qualified table names (e.g. <keyspace>.<table>).

This also prepends 'test' to the name of keyspaces used in tests, so
they are guaranteed to start with an letter (starting with digits cause
syntax errors in most statements).

Depends on D8182.

Diff Detail

Repository
rDSTO Storage manager
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D8183 (id=29542)

Could not rebase; Attempt merge onto 2205fa6e1f...

Updating 2205fa6e..1e7ede18
Fast-forward
 swh/storage/cassandra/cql.py                  | 92 ++++++++++++---------------
 swh/storage/tests/test_cassandra.py           |  4 +-
 swh/storage/tests/test_cassandra_migration.py | 18 +++---
 3 files changed, 53 insertions(+), 61 deletions(-)
Changes applied before test
commit 1e7ede1828e7ba80733d3ac17f8d6c48bab2aeab
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Aug 4 13:53:29 2022 +0200

    Stop using `USE <keyspace>` with prepared statements
    
    This caused the following warning:
WARNING  cassandra.protocol:libevreactor.py:361 Server warning: `USE <keyspace>` with prepared statements is considered to be an anti-pattern due to ambiguity in non-qualified table names. Please consider removing instances of `Session#setKeyspace(<keyspace>)`, `Session#execute("USE <keyspace>")` and `cluster.newSession(<keyspace>)` from your code, and always use fully qualified table names (e.g. <keyspace>.<table>).
```

This also prepends 'test' to the name of keyspaces used in tests, so
they are guaranteed to start with an letter (starting with digits cause
syntax errors in most statements).

commit 0aff46189a13e9f1d1d65418faa99ac1dc33d461
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date: Thu Aug 4 13:51:16 2022 +0200

cassandra: Simplify SELECT statement formatting
See https://jenkins.softwareheritage.org/job/DSTO/job/tests-on-diff/1639/ for more details.
This revision is now accepted and ready to land.Thu, Aug 4, 4:09 PM