Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

append_rows_stream.close() causes 499 error log #638

@annamuscarella

Description

@annamuscarella

I am running the example append_rows_proto2 and when setting the log level to "DEBUG", I receive the following error message as debug log:
Thread-ConsumeBidirectionalStream caught error 499 Locally cancelled by application! and will exit. Generally this is due to the RPC itself being cancelled and the error will be surfaced to the calling code.

Here is the full log output:

2023-07-12 09:32:50,699 [DEBUG] Checking None for explicit credentials as part of auth process...
2023-07-12 09:32:50,700 [DEBUG] Checking Cloud SDK credentials as part of auth process...
2023-07-12 09:32:51,590 [DEBUG] Making request: POST https://oauth2.googleapis.com/token
2023-07-12 09:32:51,593 [DEBUG] Starting new HTTPS connection (1): oauth2.googleapis.com:443
2023-07-12 09:32:51,694 [DEBUG] https://oauth2.googleapis.com:443 "POST /token HTTP/1.1" 200 None
2023-07-12 09:32:51,854 [DEBUG] Started helper thread Thread-ConsumeBidirectionalStream
2023-07-12 09:32:52,052 [DEBUG] waiting for recv.
2023-07-12 09:32:52,053 [DEBUG] recved response.
2023-07-12 09:32:52,053 [DEBUG] waiting for recv.
append_result {
  offset {
  }
}
write_stream: "projects/PROJECT_ID/datasets/bigquery_storage_sample/tables/append_rows_proto2/streams/Cig2NjEzMDNlNS0wMDAwLTI0YTctYjY3YS0zYzI4NmQ0ZTY3OTY6czE0"

2023-07-12 09:32:52,097 [DEBUG] Retrying due to , sleeping 1.0s ...
2023-07-12 09:32:52,138 [DEBUG] recved response.
2023-07-12 09:32:52,138 [DEBUG] waiting for recv.
2023-07-12 09:32:52,147 [DEBUG] recved response.
2023-07-12 09:32:52,148 [DEBUG] waiting for recv.
append_result {
  offset {
    value: 6
  }
}

append_result {
  offset {
    value: 12
  }
}

2023-07-12 09:32:53,096 [DEBUG] Stopping consumer.
2023-07-12 09:32:53,097 [DEBUG] Cleanly exiting request generator.
2023-07-12 09:32:53,097 [INFO] RPC termination has signaled streaming pull manager shutdown.
2023-07-12 09:32:53,097 [DEBUG] Thread-ConsumeBidirectionalStream caught error 499 Locally cancelled by application! and will exit. Generally this is due to the RPC itself being cancelled and the error will be surfaced to the calling code.
Traceback (most recent call last):
  File "/python-bigquery-storage/samples/venv/lib/python3.11/site-packages/google/api_core/grpc_helpers.py", line 112, in __next__
    return next(self._wrapped)
           ^^^^^^^^^^^^^^^^^^^
  File "/python-bigquery-storage/samples/venv/lib/python3.11/site-packages/grpc/_channel.py", line 475, in __next__
    return self._next()
           ^^^^^^^^^^^^
  File "/python-bigquery-storage/samples/venv/lib/python3.11/site-packages/grpc/_channel.py", line 881, in _next
    raise self
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
        status = StatusCode.CANCELLED
        details = "Locally cancelled by application!"
        debug_error_string = "None"
>

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

Traceback (most recent call last):
  File "/python-bigquery-storage/samples/venv/lib/python3.11/site-packages/google/api_core/bidi.py", line 655, in _thread_main
    response = self._bidi_rpc.recv()
               ^^^^^^^^^^^^^^^^^^^^^
  File "/python-bigquery-storage/samples/venv/lib/python3.11/site-packages/google/api_core/bidi.py", line 338, in recv
    return next(self.call)
           ^^^^^^^^^^^^^^^
  File "/python-bigquery-storage/samples/venv/lib/python3.11/site-packages/google/api_core/grpc_helpers.py", line 115, in __next__
    raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.Cancelled: 499 Locally cancelled by application!
2023-07-12 09:32:53,100 [INFO] Thread-ConsumeBidirectionalStream exiting
2023-07-12 09:32:53,100 [DEBUG] Finished stopping manager.
Writes to stream: 'projects/PROJECT_ID/datasets/bigquery_storage_sample/tables/append_rows_proto2/streams/Cig2NjEzMDNlNS0wMDAwLTI0YTctYjY3YS0zYzI4NmQ0ZTY3OTY6czE0' have been committed.

The message occurs when closing the stream:

Based on the logs, this message seems to come from https://github.com/googleapis/python-api-core/blob/main/google/api_core/bidi.py#L659C23-L659C23

This is not a catchable error, but rather just a debug message, which is very confusing. It also does not seem to affect the functionality, since the stream is committed successfully, and I can actually see the data in BigQuery.

Is this debug log safe to ignore? If not, how can I handle it since it's not a raised Error, but just a log?

Metadata

Metadata

Assignees

Labels

api: bigquerystorageIssues related to the googleapis/python-bigquery-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions