Skip to content

[Bug]: LOAD DATA PARALLEL strips U+FEFF from data after IGNORE LINES #31645

Closed as duplicate

Description

@iamlinjunhong

Is there an existing issue for the same bug?

I checked existing issues and open PRs. See Additional information for the related issues reviewed.

Branch Name

main snapshot (Loom-managed detached HEAD)

Commit ID

95341b4

Other Environment Information

  • Hardware parameters: Apple M4, arm64; Go 1.27.1.
  • OS type: macOS 15.5, Darwin 24.5.0.
  • Others: locally built single-process standalone mo-service (one CN, one TN, one LogService), DISK-V2 local/shared storage. No production modifications. GitHub main SHA was verified equal to this workspace SHA at the start of testing.

Actual Behavior

For the same 18-byte UTF-8 CSV, serial LOAD inserts HEX values 626262 and EFBBBF616161, while PARALLEL 'true' inserts 616161 and 626262. U+FEFF is a data character after the ignored header, not the file's BOM. LOAD succeeds and changes the value silently. This reproduces three times even though the small file is below parallel admission and ultimately uses one reader.

The same root cause also affects a genuine non-strict byte-range split. A 268435463-byte fixture produced [0,134217732,134217732,-1] with max_dop=2. Serial and MySQL both returned count=4097, SUM(LENGTH(s))=4100, SUM(LENGTH(pad))=268423169; parallel returned the same row count and pad sum but SUM(LENGTH(s))=4097 on two runs.

Expected Behavior

Both parallel and serial LOAD must insert exactly the two byte strings EFBBBF616161 and 626262 after ignoring the header, as MySQL 8.0.46 does for the same file and clauses (without MatrixOne's PARALLEL/STRICT extensions).

Steps to Reproduce

The scripts below connect to the test-owned service on TCP 26201 (set MO_PORT to another existing standalone service's MySQL port if necessary). The test uses root/111. No LOAD-specific CN configuration was changed.

Exact local service setup: copy etc/launch to .loom-test/launch; replace every ./mo-data path in the copied TOML files with an absolute workspace-owned .loom-test//mo-data path, and make launch.toml reference the absolute copied CN/TN/LOG configs. Set cn.port-base=38200, tn.port-base=39200, observability.status-port=27201 in all three configs. Add [cn.frontend] port=26201, portOfRpcServerInComputationEngine=40200, unix-socket="/.loom-test/mo.sock" to cn.toml. Add [hakeeper-client] service-addresses=["127.0.0.1:52201"] to each service config. Add [logservice] logservice-address="127.0.0.1:52201", raft-address="127.0.0.1:52200", gossip-address="127.0.0.1:52202", gossip-seed-addresses=["127.0.0.1:52202"] to log.toml. Run make build, then /mo-service -launch /.loom-test/launch/launch.toml -debug-http 127.0.0.1:26260 from the repository root. Wait for SQL readiness and ISCP-Task Start in its log before running the reproduction. These port changes isolate the test and are not prerequisites for the defect.

Requires Python 3 and PyMySQL. Run from the repository root:

python3 - <<'PY'
from pathlib import Path
import os,pymysql
root=Path.cwd();path=root/'.loom-test/2011f56fec05f104073456c682a473ba/bom-repro.csv'
path.parent.mkdir(exist_ok=True);path.write_bytes(b'header\n\xef\xbb\xbfaaa\nbbb\n')
for name,port,password in [('MatrixOne',int(os.getenv('MO_PORT','26201')),'111'),('MySQL 8.0',int(os.getenv('MYSQL_PORT','23506')),'')]:
 c=pymysql.connect(host='127.0.0.1',port=port,user='root',password=password,autocommit=True,charset='utf8mb4')
 try:
  with c.cursor() as q:
   q.execute('create database if not exists loom_bom_repro');q.execute('use loom_bom_repro');q.execute('drop table if exists dst');q.execute('create table dst(s varchar(32))')
   q.execute('select version()');print(name,'version',q.fetchone(),flush=True)
   for run in range(3):
    for mode in (['false','true'] if name=='MatrixOne' else ['mysql']):
     q.execute('truncate table dst')
     sql="load data infile '"+str(path)+"' into table dst fields terminated by ',' lines terminated by '\\n' ignore 1 lines"
     if name=='MatrixOne':sql+=" parallel '"+mode+"' strict 'false'"
     q.execute(sql);q.execute('select hex(s) from dst order by hex(s)')
     print(name,'run',run+1,'parallel',mode,q.fetchall(),flush=True)
   q.execute('drop database loom_bom_repro')
 finally:c.close()
PY

The MySQL comparison uses a temporary mysqld 8.0.46 on TCP 23506, initialized with --initialize-insecure; its [mysqld] config sets basedir=/opt/homebrew/opt/[email protected], datadir=/.loom-test//mysql-data, port=23506, bind-address=127.0.0.1, mysqlx=0, local-infile=1 and secure-file-priv=/.loom-test/2011f56fec05f104073456c682a473ba. The reproduction writes its file under that allowed directory. Root has an empty password. Set MYSQL_PORT when comparing against a different MySQL 8.0 instance.

Additional information

Root cause: buildLoad pre-scans IGNORE records when parallel was requested, sets FileStartOff to the header end and zeroes Tail.IgnoredLines before size-based parallel admission. CsvReader then opens a new CSVParser at this nonzero file position. CSVParser.readBlock sees parser.pos==0 and calls bom.Clean without knowing the absolute file offset; it treats data bytes EF BB BF as a new file header. Non-strict shard restarts use the same parser construction and have the same behavior.

Compatibility evidence: the reproduction below runs the same source file and standard LOAD clauses against real MySQL 8.0.46, which preserves EFBBBF616161 on all three runs. MO's serial control also preserves it. The value starts on physical line two, so this is not a disagreement about how to interpret an actual file-leading BOM.

Related issues read: #30050 is a schema-inference/file-relations design task; #31445 concerns quote-state resynchronization, while this reproduction contains no quoted or multiline fields. Neither covers this root cause. Searches for CSV BOM / BOM and open PRs found no repair. Workaround: PARALLEL 'false'. Recommended repair: preserve absolute-offset/header state across reader restarts, rather than removing U+FEFF characters from existing data.

Found by Loom bug hunt (module: custom-82082add71; tests: white-box, black-box, end-to-end, concurrency; severity: S1)

Activity

  1. added
    kind/bug
    severity/s1
    on Oct 29, 2026
  2. XuPeng-SH commented on Oct 31, 2026

    @XuPeng-SH
    Contributor

    已并入 #31232(LOAD入口参数完整性与字节保真)。本项的完整复现、版本、证据和独立验收要求已保留在主 issue,后续统一在主项跟踪,唯一负责人为 @iamlinjunhong。

    本次关闭仅为问题整理/合并,不代表缺陷已修复、测试通过或所有来源具有同一根因;各独立验收仍须完成。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions