zhangshenghang opened a new issue, #12683: URL: https://github.com/apache/seatunnel/issues/12683
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/seatunnel/issues) and found no similar issues. ### What happened A streaming/batch job writing to a **multi-node IoTDB cluster (1.3.x)** dies with: ``` org.apache.iotdb.rpc.StatementExecutionException: 400: at org.apache.iotdb.session.Session.insertByGroup(Session.java:2480) at org.apache.iotdb.session.Session.insertRecordsWithLeaderCache(Session.java:1532) at org.apache.iotdb.session.Session.insertRecords(Session.java:1148) at org.apache.seatunnel.connectors.seatunnel.iotdb.sink.IoTDBSinkClient.flush(IoTDBSinkClient.java:141) ``` In IoTDB, TSStatus **400 = REDIRECTION_RECOMMEND**: the node answered "I am not the leader of the data region owning these devices, please talk to the leader". On a cluster, **only the region leader accepts session writes**; followers (even ones holding replicas) always reply 400. Two problems in the connector: 1. `IoTDBSinkClient` opens a single session and always sends every batch to `node_urls[0]`. As soon as that node is not the leader (leader failover, load balancing, region migration — anything that moves leadership), every write is rejected. 2. The bundled `iotdb-session` 0.13.1 does not follow the redirect, and the retry loop re-sends the same batch to the same node with backoff, which can never succeed. After `max_retries` the job fails. ### What you expected to happen The sink should follow the redirection: find the node that accepts each device's writes, cache it, and keep the job running across leader changes. ### How to reproduce 1. Deploy a 3-node IoTDB 1.3.x cluster. 2. Create a database so it has at least two data regions whose leaders are not the first node of `node_urls`. 3. Run any job with the IoTDB sink; it fails on the first batch sent to `node_urls[0]`. Single-node IoTDB is not affected (that is why this is rarely seen). ### Anything else? A fix is being contributed in the linked PR: per-device leader cache, redirect-following without waiting, per-device probing for batches that mix devices of different regions, backoff only for network errors. ### Are you willing to submit a PR? - [X] Yes I am 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
