NassarX opened a new issue, #71466:
URL: https://github.com/apache/doris/issues/71466

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   ### Version
   
   4.1.5 (tag `4.1.5-release`), compute-storage decoupled mode. Source: MySQL 
8.0.46, `binlog_format=ROW`, `binlog_row_image=FULL`.
   
   The same line in `commitOffset` is on `master`, `branch-4.1` and 
`branch-4.0` (read 2026-12-05).
   
   ### What's Wrong?
   
   `DorisBatchStreamLoad.commitOffset` declares `Content-Type: 
application/json;charset=UTF-8`, but builds the body with `new 
StringEntity(param)`:
   
   
https://github.com/apache/doris/blob/4.1.5-release/fs_brokers/cdc_client/src/main/java/org/apache/doris/cdcclient/sink/DorisBatchStreamLoad.java#L546
   
   In httpcore 4.4.13 that constructor encodes as ISO-8859-1, whatever 
`file.encoding` or the locale says. `param` holds `tableSchemas`: table names, 
column names, `ENUM` and `SET` members and column defaults.
   
   What follows depends on the character:
   
   1. **A letter that Latin-1 has, such as `é`.** The byte is not valid UTF-8. 
The FE logs `JSON parse error: Invalid UTF-8 middle byte 0x74` (member `été`). 
The task fails with `commit offset failed with: HTTP/1.1 200 OK` and the binlog 
offset is not saved. Rows still arrive and the job can read `RUNNING`; it may 
also pause itself. Once the binlog files it started in are purged, it cannot 
continue.
   2. **A letter that Latin-1 lacks, such as `œ` or `€`.** It is sent as `?`. 
The body is valid, so the commit is accepted and the stored table schema is 
wrong. With `ENUM('a','cœur','€')`, rows written after an FE restart hold 
`c?ur` and `?` in Doris, while the job reads `RUNNING` with an empty error.
   3. **Two Latin-1 characters whose bytes form valid UTF-8, such as `é`.** 
The body is accepted and the schema arrives as another text (`é`).
   
   Seen on a running job, with the offset not saved: `é` in an `ENUM` member, a 
`SET` member, a column name, a table name or a string default, and a member or 
column with `é` added by `ALTER TABLE` while the job ran. Case 2 was seen with 
`ENUM` members.
   
   Seen without a cluster, by calling the client's own schema serializer and 
`commitOffset` against a local HTTP server that decodes the body as UTF-8 JSON: 
the cases above, case 3, and a schema with a CJK column name next to such 
members (accepted, changed).
   
   Not affected: column and table comments (they are not in the sent schema), 
and `é` in row values.
   
   `reportTaskFailure` in the same class builds its body the same way (from the 
source; not reproduced).
   
   ### What You Expected?
   
   The body is sent as UTF-8, as its header says. The offset is saved and the 
stored schema equals the source definition.
   
   ### How to Reproduce?
   
   MySQL:
   
   ```sql
   CREATE DATABASE toy;
   CREATE TABLE toy.t (id INT PRIMARY KEY, k ENUM('a','été','b')) CHARACTER SET 
utf8mb4;
   INSERT INTO toy.t VALUES (1,'a');
   ```
   
   Doris (fill in your MySQL host and a user with replication rights):
   
   ```sql
   CREATE DATABASE toy_raw;
   CREATE JOB toy_job ON STREAMING
   FROM MYSQL (
     "jdbc_url" = "jdbc:mysql://<mysql_host>:3306",
     "driver_url" = "mysql-connector-j-8.0.33.jar",
     "driver_class" = "com.mysql.cj.jdbc.Driver",
     "user" = "<user>", "password" = "<password>",
     "database" = "toy", "include_tables" = "t", "offset" = "initial")
   TO DATABASE toy_raw ("table.create.properties.replication_num" = "1");
   ```
   
   After the first copy, in MySQL:
   
   ```sql
   INSERT INTO toy.t VALUES (2,'été');
   ```
   
   Then in Doris:
   
   ```sql
   SELECT Status, FailedTaskCount, CurrentOffset, ErrorMsg
   FROM jobs('type'='insert') WHERE ExecuteType = 'STREAMING' AND Name = 
'toy_job';
   ```
   
   The row arrives, `FailedTaskCount` grows, and `CurrentOffset` does not come 
to hold a binlog file and position. To see the effect of a purge: restart the 
FE, write a row, pause the job, run `FLUSH BINARY LOGS` and `PURGE BINARY LOGS 
TO '<newest file>'` in MySQL, and resume. The job fails with `... no longer 
available on the server`.
   
   For the silent case, use `ENUM('a','cœur','€')`: insert `cœur`, wait, 
restart the FE, insert `cœur` again and compare the rows.
   
   ### Anything Else?
   
   Related, but not the same: #64806 and #66771 are about the JVM default 
charset on the row record path. #66771 (merged) does not
   change the `new StringEntity(param)` calls above; they are still on `master` 
(lines 546 and 644, read 2026-12-05).
   
   Suggested fix, in 
`fs_brokers/cdc_client/src/main/java/org/apache/doris/cdcclient/sink/DorisBatchStreamLoad.java`,
 in both `commitOffset` and `reportTaskFailure` (with `import 
java.nio.charset.StandardCharsets;`):
   
   ```diff
   -                            .setEntity(new StringEntity(param));
   +                            .setEntity(new StringEntity(param, 
StandardCharsets.UTF_8));
   ```
   
   `utils/SchemaChangeManager` in the same module already passes `"UTF-8"`. A 
test could commit a schema with `ENUM('été','€')` to a local HTTP server and 
compare the decoded body. The fix itself has not been built or tested.
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to