Skip to content

PYTHON-2082 Unpin session after RetryableWriteErrors from commitTransaction #451

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

Merged
merged 1 commit into from
Jul 2, 2020

Conversation

ShaneHarvey
Copy link
Member

@ShaneHarvey ShaneHarvey commented Jun 30, 2020

PYTHON-2154 PYTHON-2189 Remove 4.5 transaction test workarounds

Explanation: The StaleConfig change in PYTHON-2189 accidentally causes the test_transactions suite to ignore any failed test because there was a missing raise statement. Now that we're no longer masking test failures, this test began to fail:

ERROR: test_transactions_mongos_recovery_token_commitTransaction_retry_succeeds_on_new_mongos (test.test_transactions.TestTransactions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/shane/git/mongo-python-driver/test/__init__.py", line 442, in wrap
    return f(*args, **kwargs)
  File "/Users/shane/git/mongo-python-driver/test/__init__.py", line 442, in wrap
    return f(*args, **kwargs)
  File "/Users/shane/git/mongo-python-driver/test/__init__.py", line 442, in wrap
    return f(*args, **kwargs)
  File "/Users/shane/git/mongo-python-driver/test/test_transactions.py", line 418, in run_scenario
    self.run_scenario(scenario_def, test)
  File "/Users/shane/git/mongo-python-driver/test/utils_spec_runner.py", line 584, in run_scenario
    self.run_test_ops(sessions, collection, test)
  File "/Users/shane/git/mongo-python-driver/test/utils_spec_runner.py", line 497, in run_test_ops
    self.run_operations(sessions, collection, test['operations'])
  File "/Users/shane/git/mongo-python-driver/test/utils_spec_runner.py", line 403, in run_operations
    result = self.run_operation(sessions, collection, op.copy())
  File "/Users/shane/git/mongo-python-driver/test/utils_spec_runner.py", line 346, in run_operation
    result = cmd(**dict(arguments))
  File "/Users/shane/git/mongo-python-driver/pymongo/client_session.py", line 615, in commit_transaction
    _reraise_with_unknown_commit(exc)
  File "/Users/shane/git/mongo-python-driver/pymongo/client_session.py", line 597, in commit_transaction
    self._finish_transaction_with_retry("commitTransaction")
  File "/Users/shane/git/mongo-python-driver/pymongo/client_session.py", line 655, in _finish_transaction_with_retry
    return self._client._retry_internal(True, func, self, None)
  File "/Users/shane/git/mongo-python-driver/pymongo/mongo_client.py", line 1406, in _retry_internal
    raise last_error
WriteConcernError: Replication is being shut down

This test failure is caused by PYTHON-2082. In particular, we neglected to unpin the session on retryable commitTransaction errors. To fix the bug we unpin the session on all errors with the RetryableWriteError label.

I've already tested this change here: https://evergreen.mongodb.com/version/5efb9809c9ec447c47b57365

…action

PYTHON-2154 PYTHON-2189 Remove 4.5 transaction test workarounds
Copy link
Contributor

@prashantmital prashantmital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ShaneHarvey ShaneHarvey merged commit 4457714 into mongodb:master Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants