Skip to content

Commit

Permalink
feature(get_any_ks_cf_list): get more accurate data if table empty
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fruch committed Dec 25, 2023
1 parent c50a6c8 commit c7a08ad
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sdcm/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')

Expand Down

0 comments on commit c7a08ad

Please sign in to comment.