Skip to content

Add CorruptedTsFileException for TsFile corruption errors with file path#18304

Open
shuwenwei wants to merge 4 commits into
masterfrom
tsfile-corruption-error-message
Open

Add CorruptedTsFileException for TsFile corruption errors with file path#18304
shuwenwei wants to merge 4 commits into
masterfrom
tsfile-corruption-error-message

Conversation

@shuwenwei

Copy link
Copy Markdown
Member

Description

When a TsFile is corrupted during query execution, the original IOException from the TsFile reader is wrapped as a generic RuntimeException without the corrupted file path, making it impossible for users to locate the problem file.

This PR introduces CorruptedTsFileException to carry the corrupted TsFile path and the stage at which corruption was detected.

Key design decisions:

  • RuntimeException: so operator-layer catch (IOException) don't intercept it
  • super(message) + addSuppressed(cause): prevents getRootCause() from penetrating to the original IOException, allowing AbstractDriverThread to match it by instanceof
  • Staged error reporting: 5 stages: READ_TIMESERIES_METADATA, READ_CHUNK_DATA, LOAD_PAGE_READER, DECODE_PAGE_DATA, READ_METADATA_INDEX_NODE
  • Differentiated messages: normal queries mention corruption without file path (tell user to check logs); read_tsfile queries include the full path
  • File references (not String paths) for memory efficiency

Files changed:

  • New: CorruptedTsFileException.java — exception with Stage enum and File reference
  • ErrorHandlingUtils.java — handle CorruptedTsFileException with TSFILE_PROCESSOR_ERROR
  • AbstractDriverThread.java — match CorruptedTsFileException as abort cause
  • FileLoaderUtils.java — wrap IOException at READ_TIMESERIES_METADATA, READ_CHUNK_DATA, LOAD_PAGE_READER stages
  • SeriesScanUtil.java — wrap IOException at DECODE_PAGE_DATA stage
  • DiskChunkLoader.java / DiskAlignedChunkLoader.java — expose getTsFile() for File reference
  • ExternalTsFileQueryResource.java — wrap at READ_METADATA_INDEX_NODE stage
  • i18n: DataNodeQueryMessages.java (en + zh) — EXCEPTION_ constants for all 5 stages
  • IT: IoTDBQueryWithCorruptedTsFileIT.java — 3 test cases (metadata index + page data corruption for read_tsfile, page data for normal query)

…ath during query execution

- Introduce CorruptedTsFileException extending RuntimeException with Stage enum
  (READ_TIMESERIES_METADATA, READ_CHUNK_DATA, LOAD_PAGE_READER,
   DECODE_PAGE_DATA, READ_METADATA_INDEX_NODE)
- Uses super(message) + addSuppressed(cause) to prevent getRootCause penetration
- Carries File reference and Stage for precise error reporting
- Catch points in FileLoaderUtils, SeriesScanUtil, and DeviceCollector
  wrap IOException/RuntimeException as CorruptedTsFileException
- Normal queries: message mentions corruption, tells user to check logs (no file path)
- read_tsfile queries: message includes full TsFile path
- DiskChunkLoader/DiskAlignedChunkLoader expose getTsFile() for File reference
- ErrorHandlingUtils handles CorruptedTsFileException with TSFILE_PROCESSOR_ERROR
- AbstractDriverThread matches CorruptedTsFileException by instanceof
- AbstractDriverThread catch CorruptedTsFileException as abort cause
- i18n: add EXCEPTION_ constants for all five stages (en + zh)
- IT: IoTDBQueryWithCorruptedTsFileIT tests metadata index and page data corruption
CorruptedTsFileException is a RuntimeException and the DataNode handles it
fine without wrapping, so the catch-and-rewrap block is redundant.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 14.54545% with 94 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.03%. Comparing base (965e863) to head (a41de95).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...n/tvf/read_tsfile/ExternalTsFileQueryResource.java 0.00% 42 Missing ⚠️
...ine/execution/operator/source/FileLoaderUtils.java 17.64% 28 Missing ⚠️
...e/iotdb/db/exception/CorruptedTsFileException.java 0.00% 14 Missing ⚠️
...gine/execution/operator/source/SeriesScanUtil.java 46.66% 8 Missing ⚠️
...ngine/execution/schedule/AbstractDriverThread.java 33.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18304      +/-   ##
============================================
+ Coverage     43.02%   43.03%   +0.01%     
  Complexity      374      374              
============================================
  Files          5362     5363       +1     
  Lines        381599   381680      +81     
  Branches      49553    49567      +14     
============================================
+ Hits         164192   164275      +83     
+ Misses       217407   217405       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant