Skip to content
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

Spanner: 'test_transaction_batch_update_and_execute_dml' systest flakes with unexpected status code. #7504

Closed
tseaver opened this issue Mar 12, 2019 · 1 comment · Fixed by #9393
Assignees
Labels
api: spanner Issues related to the Spanner API. flaky testing type: process A process-related concern. May include testing, release, or the like.

Comments

@tseaver
Copy link
Contributor

tseaver commented Mar 12, 2019

From: https://source.cloud.google.com/results/invocations/1fe1c70e-9abd-44c2-ae2f-426dec16730f/targets/cloud-devrel%2Fclient-libraries%2Fgoogle-cloud-python%2Fpresubmit%2Fspanner/log

_________ TestSessionAPI.test_transaction_batch_update_and_execute_dml _________
self = <tests.system.test_system.TestSessionAPI testMethod=test_transaction_batch_update_and_execute_dml>
    def test_transaction_batch_update_and_execute_dml(self):
        retry = RetryInstanceState(_has_all_ddl)
        retry(self._db.reload)()
        session = self._db.session()
        session.create()
        self.to_delete.append(session)
        with session.batch() as batch:
            batch.delete(self.TABLE, self.ALL)
        insert_statements = list(self._generate_insert_statements())
        update_statements = [
            (
                "UPDATE contacts SET email = @email " "WHERE contact_id = @contact_id;",
                {"contact_id": 1, "email": "phreddy@example.com"},
                {"contact_id": Type(code=INT64), "email": Type(code=STRING)},
            )
        ]
        delete_statement = "DELETE contacts WHERE TRUE;"
        def unit_of_work(transaction, self):
            rows = list(transaction.read(self.TABLE, self.COLUMNS, self.ALL))
            self.assertEqual(rows, [])
            status, row_counts = transaction.batch_update(
                insert_statements + update_statements
            )
            self.assertEqual(status.code, 0)  # XXX: where are values defined?
            self.assertEqual(len(row_counts), len(insert_statements) + 1)
            for row_count in row_counts:
                self.assertEqual(row_count, 1)
            row_count = transaction.execute_update(delete_statement)
            self.assertEqual(row_count, len(insert_statements))
>       session.run_in_transaction(unit_of_work, self)
tests/system/test_system.py:859:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
google/cloud/spanner_v1/session.py:295: in run_in_transaction
    return_value = func(txn, *args, **kw)
tests/system/test_system.py:850: in unit_of_work
    self.assertEqual(status.code, 0)  # XXX: where are values defined?
E AssertionError: 10 != 0
@tseaver tseaver added testing api: spanner Issues related to the Spanner API. type: process A process-related concern. May include testing, release, or the like. flaky labels Mar 12, 2019
@tseaver tseaver changed the title Spanner: 'test_transaction_batch_update_and_execute_dml' systest flakes Spanner: 'test_transaction_batch_update_and_execute_dml' systest flakes with unexpected status code. Jun 25, 2019
@tseaver
Copy link
Contributor Author

tseaver commented Sep 27, 2019

FWIW, that status code seems to be defined in google.rpc.code_pb2.Code, see this proto, which makes it ABORTED.

>>> from google.rpc.code_pb2 import Code
>>> Code.Name(10)
'ABORTED'

@tseaver tseaver self-assigned this Oct 4, 2019
tseaver added a commit that referenced this issue Oct 22, 2019
That API can fail without raising an exception (it returns a status code
and a list of rows affected by each successfull DML statuement).
We would like for our retry mechanism to operate, so raise an exception
for non-zero status inside our unit-of-work function.

Closes #7504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. flaky testing type: process A process-related concern. May include testing, release, or the like.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant