From afbc00bb87fe13fede1e1d0d245049cbf5f8182e Mon Sep 17 00:00:00 2001 From: Dario Mirovic Date: Wed, 15 Apr 2026 13:37:27 +0200 Subject: [PATCH] test: use DROP KEYSPACE IF EXISTS in new_test_keyspace cleanup The new_test_keyspace context manager in test/cluster/util.py uses DROP KEYSPACE without IF EXISTS during cleanup. The Python driver has a known bug (scylladb/python-driver#317) where connection pool renewal after concurrent node bootstraps causes double statement execution. The DROP succeeds server-side, but the response is lost when the old pool is closed. The driver retries on the new pool, and gets ConfigurationException message "Cannot drop non existing keyspace". The CREATE KEYSPACE in create_new_test_keyspace already uses IF NOT EXISTS as a workaround for the same driver bug. This patch applies the same approach to fix DROP KEYSPACE. Fixes SCYLLADB-1538 Closes scylladb/scylladb#29487 (cherry picked from commit 40740104ab10fd4cfb19537f889dc4f511fd4d63) Closes scylladb/scylladb#29568 --- test/cluster/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/cluster/util.py b/test/cluster/util.py index 820dc025cb..afb63ac72a 100644 --- a/test/cluster/util.py +++ b/test/cluster/util.py @@ -569,7 +569,9 @@ async def new_test_keyspace(manager: ManagerClient, opts, host=None): logger.info(f"Error happened while using keyspace '{keyspace}', the keyspace is left in place for investigation") raise else: - await manager.get_cql().run_async("DROP KEYSPACE " + keyspace, host=host) + # Use DROP KEYSPACE IF EXISTS as a workaround for + # https://github.com/scylladb/python-driver/issues/317 + await manager.get_cql().run_async("DROP KEYSPACE IF EXISTS " + keyspace, host=host) previously_used_table_names = [] @asynccontextmanager