damccorm opened a new pull request, #41673:
URL: https://github.com/apache/beam/pull/41673
Fixes two issues in `StorageApiWriteUnshardedRecords` when handling Storage
Write API errors, particularly on `_default` streams:
1. **Preserve root cause and avoid misleading `"failed with invalid offset
of -1"` errors on `OUT_OF_RANGE` / `ALREADY_EXISTS`:**
- Previously, any gRPC `OUT_OF_RANGE` or `ALREADY_EXISTS` error threw
`"Append to stream <stream> failed with invalid offset of <offset>"` without
including the underlying error message or attaching it as the
`RuntimeException` cause. On `_default` streams (which use `-1` as a sentinel
for no offset), this surfaced as `"failed with invalid offset of -1"` and hid
the actual BigQuery error.
- Now checks for explicit `Exceptions.OffsetOutOfRange` /
`Exceptions.OffsetAlreadyExists` (on non-default streams with `offset >= 0`)
before reporting an invalid offset, reports `Status Code <status>` otherwise,
and includes the underlying error in both the message and exception cause.
2. **Guard offset recalculation on `AppendSerializationError` retries for
`_default` streams:**
- Matches the initial offset assignment guard (`if
(!this.useDefaultStream)`) so removing failed rows before retrying does not
increment the `-1` sentinel into non-negative offsets for subsequent queued
`AppendRowsContext` batches or corrupt `currentOffset`.
### Testing
- Added `StorageApiWriteUnshardedRecordsErrorTest` covering:
- `_default` stream `OUT_OF_RANGE` and `ALREADY_EXISTS` errors (verifying
status code, description, cause preservation, and no `"invalid offset"` message)
- Pending stream `OffsetOutOfRange` / `OffsetAlreadyExists` errors
(verifying offset message and root cause preservation)
- Pending stream non-offset `OUT_OF_RANGE` errors
- Multi-context `AppendSerializationError` retries on both `_default` and
pending streams
- Ran `spotlessCheck`, `checkstyleMain`, `checkstyleTest`,
`StorageApiWriteUnshardedRecordsErrorTest`,
`StorageApiWriteUnshardedRecordsTest`, `StorageApiWriteRetryTest`, and
`BigQueryIOWriteStorageApiBatchTest` locally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]