You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "litiliu (via GitHub)" <gi...@apache.org> on 2026/08/27 07:14:30 UTC

[I] [client] Pipelined first table-bucket writes can reset writer ID [fluss]

litiliu opened a new issue, #4121:
URL: https://github.com/apache/fluss/issues/4121

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar.
   
   
   ### Fluss version
   
   main (development)
   
   ### Please describe the bug 🐞
   
   ## Summary
   
   An idempotent writer can reset its writer ID and fail the Flink job when the first writes to a newly created table-bucket are pipelined.
   
   The client allows up to five unacknowledged requests per bucket by default. Therefore, batch sequence 1 can be sent before batch sequence 0 has been acknowledged. If the server-side writer state is still empty when sequence 1 is processed, the server returns **OutOfOrderSequenceException** with **incoming=1, current=-1**.
   
   With an unlucky response order, sequence 0 can complete before the response for sequence 1 is handled. The client then sees sequence 1 as **lastAckedBatchSequence + 1**, treats the OOO error as non-retriable, and resets the writer ID for all buckets. An older in-flight batch is then dropped with **UnknownWriterIdException**, causing the Flink job to fail over.
   
   This is a general writer/table-bucket sequencing problem and does not depend on a particular partition expression.
   
   ## Affected Apache Fluss code
   
   The failure was observed with the workload described below. The affected client logic is still present on the current Apache Fluss **main** branch at commit [16aa41abae82c20a9c642464b4fb50705110fb57](https://github.com/apache/fluss/commit/16aa41abae82c20a9c642464b4fb50705110fb57).
   
   
   ## Workload and partition layout
   
   - Primary-key upsert workload: 30,000 records/second
   - 32 buckets per partition
   - Replication factor: 2
   - Hourly partition lifecycle
   - The writer uses the default idempotence, acks, retry, dynamic partition creation, and max-inflight settings
   - The table has two partition keys: one **STRING** dimension key and one time-based hourly key
   
   The problem is not specific to a partition transform. An explicitly partitioned table is affected in the same way when a partition is created dynamically from incoming record values. Once the explicit partition is mapped to new table-buckets, writes use the same idempotent writer and per-bucket sequence path.
   
   Pre-creating the next hourly partitions is not a valid workaround for this table shape. Fluss currently rejects **table.auto-partition.num-precreate > 0** for a table with multiple partition keys:
   
   > For a partitioned table with multiple partition keys, auto pre-create is unsupported and this value must be set to 0
   
   See **TableDescriptorValidation**:  
   https://github.com/apache/fluss/blob/16aa41abae82c20a9c642464b4fb50705110fb57/fluss-server/src/main/java/org/apache/fluss/server/utils/TableDescriptorValidation.java#L609-L612
   
   In addition, the STRING partition values are determined by incoming records, so the complete set of future dimension/hour combinations cannot be enumerated in advance.
   
   ## Reproduction
   
   1. Create an explicitly partitioned primary-key table with two partition keys: a STRING dimension key and a time-based hourly key.
   2. Set 32 buckets, replication factor 2, and table.auto-partition.num-precreate=0.
   3. Leave client.writer.dynamic-create-partition.enabled=true and the idempotent writer settings at their defaults.
   4. Continuously upsert 30,000 records/second using the current hourly partition value.
   5. Keep the job running across an hour boundary so incoming records create new explicit partitions and table-buckets.
   6. Under the race, a new table-bucket receives sequence 1 while its server-side writer sequence is still -1.
   7. The OOO response eventually resets the writer ID; an old in-flight batch is then dropped and the Flink job fails.
   
   The failure is timing-dependent. More buckets and a high write rate make multiple requests and bucket responses overlap around the hour boundary.
   
   ## Server-side evidence
   
   The following lines are copied verbatim from the TabletServer log and ordered by their application timestamp:
   
   ~~~text
   2026-08-24 22:00:00,458 INFO  org.apache.fluss.server.replica.ReplicaManager               [] - Try to become leaderAndFollower for TableBucket{tableId=215, partitionId=248, bucket=21} with isr LeaderAndIsr{leader=1, leaderEpoch=0, isr=[1, 0], standbyReplicas=[0], coordinatorEpoch=31, bucketEpoch=0}, replicas: [1, 0]
   2026-08-24 22:00:00,460 INFO  org.apache.fluss.server.log.LogTablet                        [] - Loading writer state for bucket TableBucket{tableId=215, partitionId=248, bucket=21} till offset 0
   2026-08-24 22:00:00,461 INFO  org.apache.fluss.server.replica.Replica                      [] - Log loaded for bucket TableBucket{tableId=215, partitionId=248, bucket=21} with initial high watermark 0
   2026-08-24 22:00:00,768 INFO  org.apache.fluss.server.log.LogTablet                        [] - Update leaderEndOffsetSnapshot to 0 for tb TableBucket{tableId=215, partitionId=248, bucket=21} while become leader
   2026-08-24 22:00:00,785 INFO  org.apache.fluss.server.kv.KvRecoverHelper                   [] - Updated row count to 0 for tablet 'TableBucket{tableId=215, partitionId=248, bucket=21}' after recovering from log
   2026-08-24 22:00:00,786 INFO  org.apache.fluss.server.replica.Replica                      [] - TabletServer 1 becomes leader for bucket TableBucket{tableId=215, partitionId=248, bucket=21}
   2026-08-24 22:00:01,169 ERROR org.apache.fluss.server.replica.ReplicaManager               [] - Error put records to local kv on replica TableBucket{tableId=215, partitionId=248, bucket=21}
   org.apache.fluss.exception.OutOfOrderSequenceException: Out of order batch sequence for writer 6075 at offset 0 in table-bucket TableBucket{tableId=215, partitionId=248, bucket=21} : 1 (incoming batch seq.), -1 (current batch seq.)
   ~~~
   
   The same writer hit the same empty-state OOO pattern on other new table-buckets within milliseconds:
   
   ~~~text
   2026-08-24 22:00:01,160 ERROR org.apache.fluss.server.replica.ReplicaManager               [] - Error put records to local kv on replica TableBucket{tableId=215, partitionId=249, bucket=22}
   org.apache.fluss.exception.OutOfOrderSequenceException: Out of order batch sequence for writer 6075 at offset 0 in table-bucket TableBucket{tableId=215, partitionId=249, bucket=22} : 1 (incoming batch seq.), -1 (current batch seq.)
   2026-08-24 22:00:01,170 ERROR org.apache.fluss.server.replica.ReplicaManager               [] - Error put records to local kv on replica TableBucket{tableId=215, partitionId=249, bucket=17}
   org.apache.fluss.exception.OutOfOrderSequenceException: Out of order batch sequence for writer 6075 at offset 0 in table-bucket TableBucket{tableId=215, partitionId=249, bucket=17} : 1 (incoming batch seq.), -1 (current batch seq.)
   2026-08-24 22:00:01,179 ERROR org.apache.fluss.server.replica.ReplicaManager               [] - Error put records to local kv on replica TableBucket{tableId=215, partitionId=249, bucket=22}
   org.apache.fluss.exception.OutOfOrderSequenceException: Out of order batch sequence for writer 6075 at offset 0 in table-bucket TableBucket{tableId=215, partitionId=249, bucket=22} : 2 (incoming batch seq.), -1 (current batch seq.)
   ~~~
   
   ## Writer and Flink evidence
   
   These lines are copied verbatim from the writer job log. The ES export was not guaranteed to be ordered, so they are shown below in application timestamp order:
   
   ~~~text
   2026-08-24 22:00:01,486 tn="fluss-netty-client(EPOLL)-9-2" ERROR org.apache.fluss.client.write.IdempotenceManager             [] - The server returned org.apache.fluss.exception.OutOfOrderSequenceException: Out of order batch sequence for writer 6075 at offset 0 in table-bucket TableBucket{tableId=215, partitionId=248, bucket=21} : 1 (incoming batch seq.), -1 (current batch seq.) for table-bucket TableBucket{tableId=215, partitionId=248, bucket=21} with writer id 6075 and batch sequence 1.
   
   2026-08-24 22:00:04,213 tn="Source: Collection Source -> bootstrap-and-continuously-write-fluss-table -> Sink: print-bootstrap-result (1/1)#3" WARN  org.apache.flink.runtime.taskmanager.Task                    [] - Source: Collection Source -> bootstrap-and-continuously-write-fluss-table -> Sink: print-bootstrap-result (1/1)#3 (680eac2f2b4236afeb07e5f6b5a6d379_cbc357ccb763df2852fee8c4fc7d55f2_0_3) switched from RUNNING to FAILED with failure cause:
   java.util.concurrent.ExecutionException: org.apache.fluss.exception.UnknownWriterIdException: Attempted to retry sending a batch but the writer id has changed from 6075 to 6076 in the mean time. This batch will be dropped.
   
   2026-08-24 22:00:04,235 tn="flink-pekko.actor.default-dispatcher-11" INFO  org.apache.flink.runtime.dispatcher.StandaloneDispatcher     [] - Job cd0677be0ea970a7a6361525732ad723 reached terminal state FAILED.
   org.apache.flink.runtime.JobException: Recovery is suppressed by FixedDelayRestartBackoffTimeStrategy(maxNumberRestartAttempts=3, backoffTimeMS=60000)
   ~~~
   
   This establishes the failure chain:
   
   **seq=1/current=-1 OOO -> writer ID 6075 reset to 6076 -> old batch dropped -> Flink task and job FAILED**.
   
   ## Expected behavior
   
   A transient ordering failure during the first writes to a new table-bucket should not reset the writer globally or fail the Flink job. The client should preserve idempotent retry behavior until the first batch establishes the server-side sequence for that bucket.
   
   ### Solution
   
   Serialize the first request for each table-bucket under the current writer ID until it is acknowledged:
   
   - If a table-bucket has no **lastAckedBatchSequence** and already has an in-flight batch, **IdempotenceManager.canSendMoreRequests()** should return false.
   - After the first batch is acknowledged, restore the configured per-bucket pipelining limit, currently five by default.
   - Keep this gate scoped per table-bucket so unrelated buckets remain parallel.
   - Apply the same first-ack gate again after a writer ID reset.
   - Add a deterministic test that holds the first response, attempts to drain sequence 1, and verifies that sequence 1 is not sent before sequence 0 is acknowledged.
   
   This removes the **incoming=1, current=-1** window without reducing steady-state throughput after each bucket is initialized.
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


-- 
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: issues-unsubscribe@fluss.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [client] Writer job fails after OutOfOrder errors on newly created table partition [fluss]

Posted by "leekeiabstraction (via GitHub)" <gi...@apache.org>.
leekeiabstraction closed issue #4121: [client] Writer job fails after OutOfOrder errors on newly created table partition
URL: https://github.com/apache/fluss/issues/4121


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org