Skip to content

Commit a51ed11

Browse files
authored
Merge pull request #1103 from psarna/fix_deprecation_in_tracing
Tracing code uses a deprecated mechanism for fetching the first row when populating traces. The behavior is now fixed.
1 parent 3ad2d1e commit a51ed11

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cassandra/query.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,8 @@ def populate(self, max_wait=2.0, wait_for_complete=True, query_cl=None):
996996
SimpleStatement(self._SELECT_SESSIONS_FORMAT, consistency_level=query_cl), (self.trace_id,), time_spent, max_wait)
997997

998998
# PYTHON-730: There is race condition that the duration mutation is written before started_at the for fast queries
999-
is_complete = session_results and session_results[0].duration is not None and session_results[0].started_at is not None
999+
session_row = session_results.one() if session_results else None
1000+
is_complete = session_row is not None and session_row.duration is not None and session_row.started_at is not None
10001001
if not session_results or (wait_for_complete and not is_complete):
10011002
time.sleep(self._BASE_RETRY_SLEEP * (2 ** attempt))
10021003
attempt += 1
@@ -1006,7 +1007,6 @@ def populate(self, max_wait=2.0, wait_for_complete=True, query_cl=None):
10061007
else:
10071008
log.debug("Fetching parital trace info for trace ID: %s", self.trace_id)
10081009

1009-
session_row = session_results[0]
10101010
self.request_type = session_row.request
10111011
self.duration = timedelta(microseconds=session_row.duration) if is_complete else None
10121012
self.started_at = session_row.started_at

0 commit comments

Comments
 (0)