googleapis / python-spanner

Apache License 2.0
136 stars 88 forks source link

tests.system.test_session_api: test_transaction_execute_sql_w_dml_read_rollback failed #1007

Closed flaky-bot[bot] closed 1 year ago

flaky-bot[bot] commented 1 year ago

Note: #982 was also for this test, but it was closed more than 10 days ago. So, I didn't mark it flaky.


commit: 43d7aec2f2a5b84cd23279ac32ae76a2be94b61f buildURL: Build Status, Sponge status: failed

Test output
args = (session: "projects/precise-truck-742/instances/google-cloud-1694667881762/databases/test_sessions_1694668119724/sessi..._name, email) VALUES (2, \'Bharney\', \'Rhubble\', \'bharney@example.com\')"
params {
}
seqno: 1
request_options {
}
,)
kwargs = {'metadata': [('google-cloud-resource-prefix', 'projects/precise-truck-742/instances/google-cloud-1694667881762/databa...ZEH6H8mJuPDMjXQ'), ('x-goog-api-client', 'gl-python/3.8.13 grpc/1.58.0 gax/2.12.0rc1 gccl/3.40.1')], 'timeout': 3600.0}
result = <_MultiThreadedRendezvous of RPC that terminated with:
    status = StatusCode.ABORTED
    details = "Transaction was aborte...95:443 {created_time:"2023-09-14T05:09:21.840113161+00:00", grpc_status:10, grpc_message:"Transaction was aborted."}"
>
prefetch_first = True

    @functools.wraps(callable_)
    def error_remapped_callable(*args, **kwargs):
        try:
            result = callable_(*args, **kwargs)
            # Auto-fetching the first result causes PubSub client's streaming pull
            # to hang when re-opening the stream, thus we need examine the hacky
            # hidden flag to see if pre-fetching is disabled.
            # https://github.com/googleapis/python-pubsub/issues/93#issuecomment-630762257
            prefetch_first = getattr(callable_, "_prefetch_first_result_", True)
>           return _StreamingResponseIterator(
                result, prefetch_first_result=prefetch_first
            )

.nox/prerelease_deps-3-8-database_dialect-postgresql/lib/python3.8/site-packages/google/api_core/grpc_helpers.py:165: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.nox/prerelease_deps-3-8-database_dialect-postgresql/lib/python3.8/site-packages/google/api_core/grpc_helpers.py:91: in __init__
    self._stored_first_result = next(self._wrapped)
.nox/prerelease_deps-3-8-database_dialect-postgresql/lib/python3.8/site-packages/grpc/_channel.py:541: in __next__
    return self._next()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_MultiThreadedRendezvous of RPC that terminated with:
    status = StatusCode.ABORTED
    details = "Transaction was aborte...95:443 {created_time:"2023-09-14T05:09:21.840113161+00:00", grpc_status:10, grpc_message:"Transaction was aborted."}"
>

    def _next(self) -> Any:
        with self._state.condition:
            if self._state.code is None:
                event_handler = _event_handler(
                    self._state, self._response_deserializer
                )
                self._state.due.add(cygrpc.OperationType.receive_message)
                operating = self._call.operate(
                    (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),),
                    event_handler,
                )
                if not operating:
                    self._state.due.remove(cygrpc.OperationType.receive_message)
            elif self._state.code is grpc.StatusCode.OK:
                raise StopIteration()
            else:
                raise self

            def _response_ready():
                return self._state.response is not None or (
                    cygrpc.OperationType.receive_message not in self._state.due
                    and self._state.code is not None
                )

            _common.wait(self._state.condition.wait, _response_ready)
            if self._state.response is not None:
                response = self._state.response
                self._state.response = None
                return response
            elif cygrpc.OperationType.receive_message not in self._state.due:
                if self._state.code is grpc.StatusCode.OK:
                    raise StopIteration()
                elif self._state.code is not None:
>                   raise self
E                   grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
E                       status = StatusCode.ABORTED
E                       details = "Transaction was aborted."
E                       debug_error_string = "UNKNOWN:Error received from peer ipv4:142.250.107.95:443 {created_time:"2023-09-14T05:09:21.840113161+00:00", grpc_status:10, grpc_message:"Transaction was aborted."}"
E                   >

.nox/prerelease_deps-3-8-database_dialect-postgresql/lib/python3.8/site-packages/grpc/_channel.py:967: _MultiThreadedRendezvous

The above exception was the direct cause of the following exception:

sessions_database = 
sessions_to_delete = []

    @_helpers.retry_mabye_conflict
    @_helpers.retry_mabye_aborted_txn
    def test_transaction_execute_sql_w_dml_read_rollback(
        sessions_database,
        sessions_to_delete,
    ):
        # [START spanner_test_dml_rollback_txn_not_committed]
        sd = _sample_data

        session = sessions_database.session()
        session.create()
        sessions_to_delete.append(session)

        with session.batch() as batch:
            batch.delete(sd.TABLE, sd.ALL)

        transaction = session.transaction()
        transaction.begin()

        rows = list(transaction.read(sd.TABLE, sd.COLUMNS, sd.ALL))
        assert rows == []

        for insert_statement in _generate_insert_statements():
            result = transaction.execute_sql(insert_statement)
>           list(result)  # iterate to get stats

tests/system/test_session_api.py:711: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
google/cloud/spanner_v1/streamed.py:145: in __iter__
    self._consume_next()
google/cloud/spanner_v1/streamed.py:117: in _consume_next
    response = next(self._response_iterator)
google/cloud/spanner_v1/snapshot.py:88: in _restart_on_unavailable
    iterator = method(request=request)
google/cloud/spanner_v1/services/spanner/client.py:1204: in execute_streaming_sql
    response = rpc(
.nox/prerelease_deps-3-8-database_dialect-postgresql/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py:131: in __call__
    return wrapped_func(*args, **kwargs)
.nox/prerelease_deps-3-8-database_dialect-postgresql/lib/python3.8/site-packages/google/api_core/timeout.py:120: in func_with_timeout
    return func(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (session: "projects/precise-truck-742/instances/google-cloud-1694667881762/databases/test_sessions_1694668119724/sessi..._name, email) VALUES (2, \'Bharney\', \'Rhubble\', \'bharney@example.com\')"
params {
}
seqno: 1
request_options {
}
,)
kwargs = {'metadata': [('google-cloud-resource-prefix', 'projects/precise-truck-742/instances/google-cloud-1694667881762/databa...ZEH6H8mJuPDMjXQ'), ('x-goog-api-client', 'gl-python/3.8.13 grpc/1.58.0 gax/2.12.0rc1 gccl/3.40.1')], 'timeout': 3600.0}
result = <_MultiThreadedRendezvous of RPC that terminated with:
    status = StatusCode.ABORTED
    details = "Transaction was aborte...95:443 {created_time:"2023-09-14T05:09:21.840113161+00:00", grpc_status:10, grpc_message:"Transaction was aborted."}"
>
prefetch_first = True

    @functools.wraps(callable_)
    def error_remapped_callable(*args, **kwargs):
        try:
            result = callable_(*args, **kwargs)
            # Auto-fetching the first result causes PubSub client's streaming pull
            # to hang when re-opening the stream, thus we need examine the hacky
            # hidden flag to see if pre-fetching is disabled.
            # https://github.com/googleapis/python-pubsub/issues/93#issuecomment-630762257
            prefetch_first = getattr(callable_, "_prefetch_first_result_", True)
            return _StreamingResponseIterator(
                result, prefetch_first_result=prefetch_first
            )
        except grpc.RpcError as exc:
>           raise exceptions.from_grpc_error(exc) from exc
E           google.api_core.exceptions.Aborted: 409 Transaction was aborted.

.nox/prerelease_deps-3-8-database_dialect-postgresql/lib/python3.8/site-packages/google/api_core/grpc_helpers.py:169: Aborted
flaky-bot[bot] commented 1 year ago

Looks like this issue is flaky. :worried:

I'm going to leave this open and stop commenting.

A human should fix and close this.


When run at the same commit (43d7aec2f2a5b84cd23279ac32ae76a2be94b61f), this test passed in one build (Build Status, Sponge) and failed in another build (Build Status, Sponge).