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
This commit is contained in:
Dario Mirovic
2026-04-15 13:37:27 +02:00
committed by Marcin Maliszkiewicz
parent ad7647c3c7
commit 40740104ab

View File

@@ -446,7 +446,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