适用版本
OBLOADER V2.x 及以上版本。
ODC V3.4.0 及以上版本。
问题现象
使用 OBLOADER 导入第三方工具导出的 CSV 数据文件或使用 CSV 文件的绝对路径导入,任务失败报错 Error: Incorrect integer value, 发现 Count 列数值减1,实际已经导入成功。
# ./obloader -h xxx -P 2883 -u root -p xxx --no-sys -c oio_cluster -t mysql -D test --csv --table 'abc' --external-data -f /root/fuyu/test/data/test/TABLE/abc.0.0.csv
2023-07-19 13:32:26 [INFO] Parsed args:
[--csv] true
[--file-path] /root/fuyu/test
[--no-sys] true
[--host] 11.xxx.xx.xxx
[--port] 2883
[--user] root
[--tenant] mysql
[--cluster] oio_cluster
[--password] ******
[--database] test
[--sys-user] root
[--table] [abc]
[--external-data] true
2023-07-19 13:32:26 [INFO] Load jdbc driver class: "com.oceanbase.jdbc.Driver" finished
2023-07-19 13:32:27 [INFO] Manifest: "/root/fuyu/test/MANIFEST.bin" has been saved
2023-07-19 13:32:27 [INFO] Found 1 empty tables before executing.... Elapsed: 30.69 ms
2023-07-19 13:32:27 [INFO] Binding table: "abc" to the file: "/root/fuyu/test/data/test/TABLE/abc.0.0.csv" finished
2023-07-19 13:32:27 [INFO] Find 1 resources in local path: "/root/fuyu/test" success. Elapsed: 16.93 ms
2023-07-19 13:32:27 [INFO] Split 1 data files to 1 subfiles by 64.0 MB success. Elapsed: 17.58 ms
2023-07-19 13:32:27 [INFO] Ignore to clean any tables as --truncate-table or --delete-from-table is not specified
2023-07-19 13:32:27 [INFO] Query table entry and primary key for table: "abc" finished. Remain: 0
2023-07-19 13:32:27 [WARN] Calculate leader of table "abc" failed, treat it as non-partition table. Remain: 0
2023-07-19 13:32:27 [INFO] Waiting to refresh observer load status ......
2023-07-19 13:32:27 [INFO] Refresh observer load status success. Table: "abc". Remain: 0
2023-07-19 13:32:27 [INFO] Refresh observer load status finished. Elapsed: 2.814 ms
2023-07-19 13:32:27 [INFO] Use c.l.d.SleepingWaitStrategy as available cpu(s) is 32
2023-07-19 13:32:27 [INFO] Create 16 slots for ring buffer finished. [0.0.0.0]
2023-07-19 13:32:27 [INFO] Start 64 database writer threads finished. [0.0.0.0]
2023-07-19 13:32:27 [INFO] Start 64 record file reader threads success
2023-07-19 13:32:27 [WARN] Retry Table: "abc", Partition: 0. Records: 4. Error: Incorrect integer value. Retry Mode: SERIAL.
2023-07-19 13:32:27 [INFO] File: "/root/fuyu/test/data/test/TABLE/abc.0.0.csv" has been parsed finished
2023-07-19 13:32:28 [INFO] Wait for the all the workers to drain of published events then halt the workers
2023-07-19 13:32:28 [INFO] Close connection count: 5 of the DataSource. Key: BIZ
2023-07-19 13:32:28 [INFO] Shutdown task context finished
2023-07-19 13:32:28 [ERROR] Error: Incorrect integer value
2023-07-19 13:32:28 [INFO] ---------- Finished Tasks: 1 Running Tasks: 0 Progress: 100.00% ----------
2023-07-19 13:32:28 [INFO]
All Load Tasks Finished:
----------------------------------------------------------------------------------------------------------------------------
No.# | Type | Name | Count | Status
----------------------------------------------------------------------------------------------------------------------------
1 | TABLE | abc | 4 -> 3 | FAILURE
----------------------------------------------------------------------------------------------------------------------------
Total Count: 3 End Time: 2023-07-19 13:32:28
2023-07-19 13:32:28 [INFO] Load record finished. Total Elapsed: 1.480 s
2023-07-19 13:32:28 [ERROR] System exit 1
# mysql -uroot@mysql -hxxx -P2881 -pxxx test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 3221660937
Server version: 5.7.25 OceanBase 3.2.4.4 (r104010012023062711-948a854473017c1b16a1831861009c051db81e3c) (Built Jun 27 2023 11:45:51)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [test]> select * from abc;
+------+------+
| name | id |
+------+------+
| aa | 1 |
| bb | 2 |
| cc | 3 |
+------+------+
3 rows in set (0.00 sec)
使用 ODC 按默认配置(未勾选 跳过首行)导入 CSV 文件报同样错误 test.abc: Incorrect integer value。
2023-07-19 11:22:33 [INFO] Wait for the all the workers to drain of published events then halt the workers
2023-07-19 11:22:33 [INFO] Close connection count: 5 of the DataSource. Key: BIZ
2023-07-19 11:22:33 [INFO] shutdown task context finished
2023-07-19 11:22:33 [INFO] ---------- Finished Tasks: 1 Running Tasks: 0 Progress: 100.00% ----------
2023-07-19 11:22:33 [INFO]
All Load Tasks Finished:
----------------------------------------------------------------------------------------------------------------------------
No.# | Type | Name | Count | Status
----------------------------------------------------------------------------------------------------------------------------
1 | TABLE | abc | 4 -> 0 | FAILURE
----------------------------------------------------------------------------------------------------------------------------
Total Count: 0 End Time: 2023-07-19 11:22:33
2023-07-19 11:22:33 [WARN] Failed to execute data transfer task
java.lang.IllegalStateException: test.abc: Incorrect integer value
at com.oceanbase.odc.service.datatransfer.task.BaseDataTransferTask.syncWaitFinished(BaseDataTransferTask.java:167) ~[classes!/:?]
at com.oceanbase.odc.service.datatransfer.task.BaseDataTransferTask.call(BaseDataTransferTask.java:128) ~[classes!/:?]
问题原因
导入第三方工具导出的 CSV 数据文件或使用 CSV 文件的绝对路径导入时,需要查看 CSV 文件中第一行是否为表的字段名,若第一行为字段名,OBLOADER 导入数据时会将字段名当作数据导入,从而会出现类似 Error: Incorrect integer value 或 Error: ORA-01722: invalid number 的错误,输出结果 Count 列会减少一条数据,如 4 -> 3,实际现象如下。
# cat abc.0.0.csv
'name','id'
'aa',1
'bb',2
'cc',3
解决方法
若使用 OBLOADER 导入增加
--skip-header选项,跳过 CSV/CUT 文件的第一行数据。若使用 ODC 导入,勾选 跳过首行。
