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 'None' status code. #9534

Closed
tseaver opened this issue Oct 24, 2019 · 1 comment · Fixed by #9579
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 Oct 24, 2019

Similar to #7504, but this time the status code is None.

From this CI failure:

_________ 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._check_batch_status(status.code)
            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:874:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
google/cloud/spanner_v1/session.py:299: in run_in_transaction
    return_value = func(txn, *args, **kw)
tests/system/test_system.py:865: in unit_of_work
    self._check_batch_status(status.code)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

status_code = 10

    @staticmethod
    def _check_batch_status(status_code):
        if status_code != code_pb2.OK:
>           raise exceptions.from_grpc_status(status_code, "batch_update failed")
E           google.api_core.exceptions.GoogleAPICallError: None batch_update failed
@tseaver
Copy link
Contributor Author

tseaver commented Oct 31, 2019

The status_code isn't actually None, but 10 (for an aborted transaction). However, the call to exceptions.from_grpc_status to convert that status to an exception fails to look up the Aborted class, because it wants an instance of the grpc.StatusCode enum, and so it returns a generic exception, with no status code.

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.

2 participants