From c7a08adaf756d94050cc179da52060f3d5db17f0 Mon Sep 17 00:00:00 2001 From: Israel Fruchter Date: Sun, 24 Dec 2023 11:19:48 +0200 Subject: [PATCH] feature(get_any_ks_cf_list): get more accurate data if table empty since in some cases (twcs as example), we have table with lots of tombstones, and our query with limit 10, can come up with no data cause of that, using cfstats would be bit more lengthy but more accurate for figuring if the table has data or not. --- sdcm/cluster.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sdcm/cluster.py b/sdcm/cluster.py index 356cd3a456..0fb7dc7023 100644 --- a/sdcm/cluster.py +++ b/sdcm/cluster.py @@ -3524,8 +3524,12 @@ def execute_cmd(cql_session, entity_type): has_data = False try: - stmt = SimpleStatement(f"SELECT * FROM {table_name}", fetch_size=10) - has_data = bool(cql_session.execute(stmt).one()) + res = db_node.run_nodetool(sub_cmd='cfstats', args=table_name, timeout=300, + warning_event_on_exception=( + Failure, UnexpectedExit, Libssh2_UnexpectedExit,), + publish_event=False, retry=0) + cf_stats = db_node._parse_cfstats(res.stdout) # pylint: disable=protected-access + has_data = bool(cf_stats['Number of partitions (estimate)']) except Exception as exc: # pylint: disable=broad-except self.log.warning(f'Failed to get rows from {table_name} table. Error: {exc}')