-
Notifications
You must be signed in to change notification settings - Fork 551
query: fix deprecation warning for tracing #1103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
query: fix deprecation warning for tracing #1103
Conversation
@@ -996,7 +996,8 @@ def populate(self, max_wait=2.0, wait_for_complete=True, query_cl=None): | |||
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 | |||
session_row = session_results.one() if session_results else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very big 👍 to moving session_row declaration higher here and using it for both the wait test and subsequent operations!
cassandra/query.py
Outdated
@@ -996,7 +996,8 @@ def populate(self, max_wait=2.0, wait_for_complete=True, query_cl=None): | |||
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 | |||
session_row = session_results.one() if session_results else None | |||
is_complete = session_results and session_row.duration is not None and session_row.started_at is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems slightly odd to look at session_results again here. Should this perhaps be:
is_complete = session_row is not None and session_row.duration is not None and session_row.started_at is not None
Rationale is that before we knew session_results[0] (the equivalent to session_row in the new impl) was non-null since we'd already validated that session_results contained at least one row (via the boolean check in "session_results and session_results[0].duration..."). We don't have that guarantee anymore; now it's quite possible that session_row could be None.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely, it makes more sense to check session_row
here, thanks
@psarna Thanks for the pull request! This is a good find; I had a minor question on the PR itself but overall this looks pretty good. Have you signed the Contributor License Agreement for contributions to DataStax open source projects? If not you can find it at https://cla.datastax.com. Thanks! |
Tracing code uses a deprecated mechanism for fetching the first row when populating traces. The behavior is now fixed.
5436180
to
d0f1ec2
Compare
Signed, thanks |
Thanks @psarna, this looks good! |
This commit provides a fix to the situation when iterating on a ResultSet, the driver aborts the iteration if the server returns an empty page even if there are next pages available. Python driver is affected by the same problem as JAVA-2934 This fix is similar to apache/cassandra-java-driver#1544
…to sync_with_upstream * 'master' of https://github.com/datastax/python-driver: Merge pull request datastax#1126 from eamanu/fix-typos PYTHON-1294: Upgrade importlib-metadata to a much newer version Add tests for recent addition of execution profile support to cassandra.concurrent Merge pull request datastax#1122 from andy-slac/concurrent-execution-profiles Merge pull request datastax#1119 from datastax/python-1290 Merge pull request datastax#1117 from datastax/remove_unittest2 Removing file unexpectedly included in previous PR Merge pull request datastax#1114 from haaawk/stream_ids_fix Merge pull request datastax#1116 from Orenef11/fix_default_argument_value Comment update following off of datastax#1110 Merge pull request datastax#1103 from numberly/fix_empty_paging Merge pull request datastax#1103 from psarna/fix_deprecation_in_tracing Fixes to the Travis build. (datastax#1111)
…to sync_with_upstream_2 * 'master' of https://github.com/datastax/python-driver: Merge pull request datastax#1126 from eamanu/fix-typos PYTHON-1294: Upgrade importlib-metadata to a much newer version Add tests for recent addition of execution profile support to cassandra.concurrent Merge pull request datastax#1122 from andy-slac/concurrent-execution-profiles Merge pull request datastax#1119 from datastax/python-1290 Merge pull request datastax#1117 from datastax/remove_unittest2 Removing file unexpectedly included in previous PR Merge pull request datastax#1114 from haaawk/stream_ids_fix Merge pull request datastax#1116 from Orenef11/fix_default_argument_value Comment update following off of datastax#1110 Merge pull request datastax#1103 from numberly/fix_empty_paging Merge pull request datastax#1103 from psarna/fix_deprecation_in_tracing Fixes to the Travis build. (datastax#1111)
In commit 0a71151 I wanted to avoid a incorrect deprecation warning from the Python driver but fixed it in an incorrect way. I never noticed the fix was incorrect because the test was already xfailing, and the incorrect fix just made it fail differently... In this patch I revert that commit. With this revert, I am *not* bringing back the spurious warning - the Python driver bug was already fixed in datastax/python-driver#1103 - so developers with a fairly recent version will no longer see the spurious warning. Both old and new drivers will at least do the correct thing, as it was before that unfortunate commit. Fixes scylladb#8752. Signed-off-by: Nadav Har'El <[email protected]>
In commit 0a71151 I wanted to avoid a incorrect deprecation warning from the Python driver but fixed it in an incorrect way. I never noticed the fix was incorrect because the test was already xfailing, and the incorrect fix just made it fail differently... In this patch I revert that commit. With this revert, I am *not* bringing back the spurious warning - the Python driver bug was already fixed in datastax/python-driver#1103 - so developers with a fairly recent version will no longer see the spurious warning. Both old and new drivers will at least do the correct thing, as it was before that unfortunate commit. Fixes #8752. Signed-off-by: Nadav Har'El <[email protected]> Closes #14002
Tracing code uses a deprecated mechanism for fetching the first row
when populating traces. The behavior is now fixed.