Skip to content

feat: 26786 Stop MerkleDb compaction during freeze - #26966

Draft
thenswan wants to merge 3 commits into
mainfrom
26786-stop-compaction-on-freeze-with-refactoring
Draft

feat: 26786 Stop MerkleDb compaction during freeze#26966
thenswan wants to merge 3 commits into
mainfrom
26786-stop-compaction-on-freeze-with-refactoring

Conversation

@thenswan

Copy link
Copy Markdown
Contributor

Summary

Stop MerkleDb background compaction when the platform enters FREEZING.

VirtualMapStateLifecycleManager now listens for platform status changes and, on FREEZING, disables new compaction work and interrupts running compactors without waiting for them to finish.

Why this design

The platform status listener previously lived in platform-core. state-impl could not use it directly because platform-core already depends on state-impl, which would create a dependency cycle.

The notification contracts were moved to consensus-model, where the platform status already lives. This allows VirtualMapStateLifecycleManager to implement the listener directly.

Compared with forwarding the status through platform wiring, StateModule, or the Hedera application layer, this keeps the storage decision in the component that owns the active VirtualMap family and avoids introducing MerkleDb-specific behavior into unrelated layers.

Why stop on FREEZING

Stopping compaction is a reaction to the node entering the freeze lifecycle, not to a snapshot being written. The freeze snapshot is only one consequence of that status change, so SignedStateFileWriter is not the natural place to control background compaction.

VirtualMapStateLifecycleManager owns the active VirtualMap family and has direct access to its shared data source. Handling FREEZING there keeps the lifecycle decision next to the resource it affects.

It also happens earlier than the snapshot. The manager disables new submissions and interrupts running compactors without waiting, allowing hashing, signing, and snapshot creation to continue. Since all maps in the family share the same data source, freeze-snapshot flushes cannot start new compaction work.

The existing blocking operation remains available for data-source shutdown. Compaction does not need to be re-enabled because the node is restarted after the upgrade.

Commit structure

The PR is split into two commits to make review easier:

  1. Move the notification contracts and platform-status listener into consensus-model.
  2. Register VirtualMapStateLifecycleManager as a listener, add the non-blocking compaction operation, and stop compaction on FREEZING.

Related issue(s):

Fixes #26786

Signed-off-by: Nikita Lebedev <nikita.lebedev@limechain.tech>
Signed-off-by: Nikita Lebedev <nikita.lebedev@limechain.tech>
@lfdt-bot

lfdt-bot commented Aug 25, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Signed-off-by: Nikita Lebedev <nikita.lebedev@limechain.tech>
@thenswan thenswan self-assigned this Aug 25, 2026
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../java/com/swirlds/merkledb/MerkleDbDataSource.java 0.00% 2 Missing ⚠️
...ava/org/hiero/consensus/ConsensusLayerFactory.java 0.00% 2 Missing ⚠️

Impacted file tree graph

@@             Coverage Diff              @@
##               main   #26966      +/-   ##
============================================
+ Coverage     70.50%   70.53%   +0.03%     
  Complexity    11692    11692              
============================================
  Files          2586     2586              
  Lines        108484   108493       +9     
  Branches      12146    12147       +1     
============================================
+ Hits          76490    76530      +40     
+ Misses        28014    27982      -32     
- Partials       3980     3981       +1     
Files with missing lines Coverage Δ Complexity Δ
...edera/node/app/info/CurrentPlatformStatusImpl.java 100.00% <ø> (ø) 0.00 <0.00> (ø)
...ero/consensus/model/notification/DispatchMode.java 100.00% <ø> (ø) 0.00 <0.00> (?)
...ro/consensus/model/notification/DispatchOrder.java 100.00% <ø> (ø) 0.00 <0.00> (?)
...notification/PlatformStatusChangeNotification.java 100.00% <ø> (ø) 0.00 <0.00> (?)
...wirlds/common/notification/NotificationEngine.java 50.00% <ø> (ø) 0.00 <0.00> (ø)
...ification/internal/AbstractNotificationEngine.java 18.51% <ø> (ø) 0.00 <0.00> (ø)
...notification/internal/AsyncNotificationEngine.java 10.34% <ø> (ø) 0.00 <0.00> (ø)
...lds/common/notification/internal/DispatchTask.java 0.00% <ø> (ø) 0.00 <0.00> (ø)
...irlds/common/notification/internal/Dispatcher.java 0.00% <ø> (ø) 0.00 <0.00> (ø)
...wirlds/merkledb/MerkleDbCompactionCoordinator.java 88.37% <100.00%> (-1.09%) 0.00 <0.00> (ø)
... and 5 more

... and 22 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

testlens-app Bot commented Aug 25, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 1eec3f5
▶️ Tests: 38127 executed
⚪️ Checks: 50/50 completed


Learn more about TestLens at testlens.app/docs.

@imalygin imalygin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach is suboptimal, as it introduces dependency on Platform/Consensus modules. Keep in mind, that swirlds-state-api and swirlds-state-impl modules are used in Block Node which cannot depend on the platform

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.

MerkleDb file compaction issues during freeze upgrade

3 participants