[import] IMPORT INTO reports success and leaves a missing secondary index when a chunk writer Close fails
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
> Evidence status: confirmed.
### 1. Minimal reproduce step (Required)
```sql
Create a table with a secondary index and a three-row CSV. Run file IMPORT INTO with THREAD=1 and CHECKSUM_TABLE=off. Inject one index EngineWriter.Close error before its final flush. Compare the import terminal status, table scan, forced-index scan, and ADMIN CHECK TABLE.
```
### 2. What did you expect to see? (Required)
A terminal writer Close failure must fail the chunk and dominate task success. No import may be reported finished while required row or index KVs are missing.
### 3. What did you see instead? (Required)
The job is finished with client exit 0 and Imported_Rows=3. The table scan returns 3, the forced index scan returns 0, and ADMIN CHECK TABLE reports ERROR 8223.
### 4. What is your TiDB version? (Required)
master 13282a8bd06b; file IMPORT INTO local sort with checksum off or optional
Likely root cause and fix direction
ProcessChunk defers data and index EngineWriter.Close, logs Close errors, but returns only the earlier ProcessChunkWithWriter result. Close is the final flush and destroys the writer buffer, so the task imports incomplete engines as successful.
Contributor guide
Research direction
Start at ProcessChunk and its deferred data and index EngineWriter.Close calls, then run the minimal SQL/CSV reproduction with THREAD=1 and CHECKSUM_TABLE=off. Verify that an injected Close error fails the chunk and import, rather than reporting success; table and forced-index scans should retain all required KVs and ADMIN CHECK TABLE should pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100