Description
When running a Flink streaming job using the BigQuery Sink with DeliveryGuarantee.EXACTLY_ONCE, the job fails during recovery if a task manager (pod) shuts down and restarts. The connector attempts to append to a BigQuery stream that has already been finalized, resulting in an INVALID_ARGUMENT exception. This leads to repeated job failures after restarts.
This issue occurs in a distributed setup (e.g., 4 task managers), where Flink restores state from checkpoints, but the stored stream ID is no longer appendable. The connector does not automatically create a new stream during recovery, causing the commit to fail.
Steps to Reproduce
- Set up a Flink job with the BigQuery Sink:
- Use
BigQuerySinkConfig with DeliveryGuarantee.EXACTLY_ONCE.
- Parallelism >1 (e.g., 4 task managers).
- Sink writes to a partitioned table (e.g., on "etl_date" field).
- Example config snippet:
DeliveryGuarantee deliveryGuarantee = DeliveryGuarantee.EXACTLY_ONCE;
BigQuerySinkConfig<GenericRecord> sinkConfig = BigQuerySinkConfig.<GenericRecord>newBuilder()
.connectOptions(BigQueryConnectOptions.builder()
.project("xxx")
.dataset("xxx")
.table("xxx")
.build())
.deliveryGuarantee(deliveryGuarantee)
.serializer(new AvroToProtoSerializer())
.enableTableCreation(true)
.partitionField("etl_date")
.partitionExpirationMillis(45L * 24L * 60L * 60L * 1000L)
.build();
- Run the job in a cluster (e.g., Google Cloud Dataproc or Kubernetes) processing unbounded data (e.g., from Kafka).
- Simulate a failure: Shut down one task manager pod (e.g., kill pod in K8s).
- Flink attempts to recover from checkpoint, but the commit fails with the error.
Environment
- Flink version: 1.19.1
- Connector version: 1.11
- Java version: 17
- Deployment: Kubernetes
- BigQuery details: Writing to table (time-partitioned on "etl_date" as string "yyyy-MM-dd").
- Checkpoint interval: [e.g., 1 minute]
Description
When running a Flink streaming job using the BigQuery Sink with
DeliveryGuarantee.EXACTLY_ONCE, the job fails during recovery if a task manager (pod) shuts down and restarts. The connector attempts to append to a BigQuery stream that has already been finalized, resulting in anINVALID_ARGUMENTexception. This leads to repeated job failures after restarts.This issue occurs in a distributed setup (e.g., 4 task managers), where Flink restores state from checkpoints, but the stored stream ID is no longer appendable. The connector does not automatically create a new stream during recovery, causing the commit to fail.
Steps to Reproduce
BigQuerySinkConfigwithDeliveryGuarantee.EXACTLY_ONCE.Environment