Skip to content

Use MinFolderOccupiedSpaceFirstStrategy for IoTConsensus recv and all… - #18020

Merged
jt2594838 merged 3 commits into
apache:masterfrom
hongzhi-gao:fix/iotconsensus-min-folder-occupied-recv
Jun 25, 2026
Merged

jt2594838 merged 3 commits into
apache:masterfrom
hongzhi-gao:fix/iotconsensus-min-folder-occupied-recv

Conversation

@hongzhi-gao

@hongzhi-gao hongzhi-gao commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

IoTConsensus receive folder strategy

The IoTConsensus snapshot receive folder always uses MinFolderOccupiedSpaceFirstStrategy (balances by least-occupied space), independent of dn_multi_dir_strategy.

Allow the strategy in cluster mode + NPE fix

Adds MinFolderOccupiedSpaceFirstStrategy to CLUSTER_ALLOWED_MULTI_DIR_STRATEGIES. Also fixes an NPE in the dn_multi_dir_strategy validation rollback path (IoTDBDescriptor): the previous value can be null at startup, so .trim() masked the real "cluster mode only allows ..." error.

Keep a TsFile and its companions together across multiple data dirs

With multiple data dirs, the fragments of one TsFile (.tsfile / .tsfile.resource / .tsfile.mods2) can be received into different disks, causing cross-disk copies (or lost mods) at load. Two changes keep a group together:

  • Receiver (IoTConsensusServerImpl#receiveSnapshotFragment): selects the receive folder once per TsFile group (key = file name up to the first ., matching SnapshotLoader) via a per-snapshotId ConcurrentHashMap#computeIfAbsent; the map is cleared on load/cleanup.
  • Loader (SnapshotLoader#loadSnapshotFromMultipleDirs): a shared fileTarget relinks a TsFile and its companions into the same data dir even when received across different disks.

Integration tests

  • Adds DataNodeConfig#setDnMultiDirStrategy.
  • IoTDBRegionMigrateWithDeletionMultiDataDirIT (tree) and IoTDBRegionMigrateWithDeletionMultiDataDirTableIT (table, @TableClusterIT): 1C3D + IoTConsensus + multiple data dirs; a deletion must survive region migration.

This PR has:

  • been self-reviewed.
  • added integration tests.
  • been tested in a test IoTDB cluster.

Key changed/added classes in this PR
  • IoTConsensusServerImpl
  • SnapshotLoader
  • DataRegionConsensusImpl
  • IoTDBConfig / IoTDBDescriptor
  • DataNodeConfig / MppDataNodeConfig / RemoteDataNodeConfig
  • IoTDBRegionMigrateWithDeletionMultiDataDirIT / IoTDBRegionMigrateWithDeletionMultiDataDirTableIT

…ow it in cluster

- IoTConsensus snapshot receive folder now always uses
  MinFolderOccupiedSpaceFirstStrategy, balancing received files by least
  occupied space independent of the global dn_multi_dir_strategy.
- Allow MinFolderOccupiedSpaceFirstStrategy in cluster mode
  (CLUSTER_ALLOWED_MULTI_DIR_STRATEGIES) so it can be configured for DataNodes.
- Fix NPE in the dn_multi_dir_strategy validation rollback path when the
  previous value is null, so the informative RuntimeException surfaces.
- IT: add DataNodeConfig.setDnMultiDirStrategy and exercise the strategy in
  IoTDBRegionMigrateWithDeletionMultiDataDirIT.
When IoTConsensus spreads snapshot fragments across recv folders, disable keepSameDiskWhenLoading so fileTarget groups companion files on one data dir.
…s receiver

receiveSnapshotFragment now selects the receive folder once per TsFile group
(fileKey = file name before the first '.', matching SnapshotLoader) via a
per-snapshotId ConcurrentHashMap.computeIfAbsent, so a TsFile and its
.resource/.mods companions land in the same receive folder and the load phase
relinks them within one data dir instead of falling back to a cross-disk copy.
The mapping is dropped once the snapshot is loaded or cleaned up.

Convert IoTDBRegionMigrateWithDeletionMultiDataDirIT to the tree model and add
the table-model twin IoTDBRegionMigrateWithDeletionMultiDataDirTableIT
(@TableClusterIT) so both cluster CI profiles cover the snapshot mods transfer.
@jt2594838
jt2594838 merged commit c98bc5a into apache:master Jun 25, 2026
40 checks passed
MileaRobertStefan pushed a commit to MileaRobertStefan/iotdb that referenced this pull request Jun 26, 2026
apache#18020)

* Use MinFolderOccupiedSpaceFirstStrategy for IoTConsensus recv and allow it in cluster

- IoTConsensus snapshot receive folder now always uses
  MinFolderOccupiedSpaceFirstStrategy, balancing received files by least
  occupied space independent of the global dn_multi_dir_strategy.
- Allow MinFolderOccupiedSpaceFirstStrategy in cluster mode
  (CLUSTER_ALLOWED_MULTI_DIR_STRATEGIES) so it can be configured for DataNodes.
- Fix NPE in the dn_multi_dir_strategy validation rollback path when the
  previous value is null, so the informative RuntimeException surfaces.
- IT: add DataNodeConfig.setDnMultiDirStrategy and exercise the strategy in
  IoTDBRegionMigrateWithDeletionMultiDataDirIT.

* Fix multi-recv snapshot loading to keep tsfile and mods together

When IoTConsensus spreads snapshot fragments across recv folders, disable keepSameDiskWhenLoading so fileTarget groups companion files on one data dir.

* Group snapshot companion files into one receive folder on IoTConsensus receiver

receiveSnapshotFragment now selects the receive folder once per TsFile group
(fileKey = file name before the first '.', matching SnapshotLoader) via a
per-snapshotId ConcurrentHashMap.computeIfAbsent, so a TsFile and its
.resource/.mods companions land in the same receive folder and the load phase
relinks them within one data dir instead of falling back to a cross-disk copy.
The mapping is dropped once the snapshot is loaded or cleaned up.

Convert IoTDBRegionMigrateWithDeletionMultiDataDirIT to the tree model and add
the table-model twin IoTDBRegionMigrateWithDeletionMultiDataDirTableIT
(@TableClusterIT) so both cluster CI profiles cover the snapshot mods transfer.
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.

2 participants