From 6fb7c6f20502d16c8c752941528ee3a20951b38d Mon Sep 17 00:00:00 2001 From: Alan Boudreault Date: Mon, 24 Apr 2017 12:09:10 -0400 Subject: [PATCH 1/2] Make sure all trace mutations are there before considering it as complete --- cassandra/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cassandra/query.py b/cassandra/query.py index 9865fb85..2edaf3b3 100644 --- a/cassandra/query.py +++ b/cassandra/query.py @@ -925,7 +925,7 @@ class QueryTrace(object): session_results = self._execute( SimpleStatement(self._SELECT_SESSIONS_FORMAT, consistency_level=query_cl), (self.trace_id,), time_spent, max_wait) - is_complete = session_results and session_results[0].duration is not None + is_complete = session_results and session_results[0].duration is not None and session_results[0].started_at is not None if not session_results or (wait_for_complete and not is_complete): time.sleep(self._BASE_RETRY_SLEEP * (2 ** attempt)) attempt += 1 From 5b143c9c128071cdbc8db40a4e38b13c9b550b9a Mon Sep 17 00:00:00 2001 From: Alan Boudreault Date: Mon, 24 Apr 2017 12:38:37 -0400 Subject: [PATCH 2/2] add comment --- cassandra/query.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cassandra/query.py b/cassandra/query.py index 2edaf3b3..24a4a0ee 100644 --- a/cassandra/query.py +++ b/cassandra/query.py @@ -925,6 +925,7 @@ class QueryTrace(object): session_results = self._execute( SimpleStatement(self._SELECT_SESSIONS_FORMAT, consistency_level=query_cl), (self.trace_id,), time_spent, max_wait) + # PYTHON-730: There is race condition that the duration mutation is written before started_at the for fast queries is_complete = session_results and session_results[0].duration is not None and session_results[0].started_at is not None if not session_results or (wait_for_complete and not is_complete): time.sleep(self._BASE_RETRY_SLEEP * (2 ** attempt))