Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement container db folder cleanup on startup #746

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

tmpolaczyk
Copy link
Contributor

Container database folders are normally removed when the collator gets unassigned. However, if the collator stops the node right before being unassigned, and then starts it later, the container db will not be removed. The db will be removed the next time the collator is assigned and unassigned from that container chain, which may never happen.

To fix this edge case, this PR introduces a new db folder cleanup functionality. When the node starts, it will check the container folders and delete all of them except the ones it is assigned to as a collator. This check is only performed once, the first time a finalized block is imported.

Copy link
Contributor

github-actions bot commented Nov 14, 2024

WASM runtime size check:

Compared to target branch

dancebox runtime: 1412 KB (no changes) ✅

flashbox runtime: 832 KB (no changes) ✅

dancelight runtime: 2008 KB (no changes) ✅

container chain template simple runtime: 1088 KB (no changes) ✅

container chain template frontier runtime: 1388 KB (no changes) ✅

Copy link
Contributor

github-actions bot commented Nov 14, 2024

Coverage Report

(master)

@@                     Coverage Diff                      @@
##           master   tomasz-db-folder-cleanup      +/-   ##
============================================================
- Coverage   65.47%                     65.34%   -0.13%     
  Files         310                        310              
+ Lines       54041                      54174     +133     
============================================================
+ Hits        35379                      35395      +16     
+ Misses      18662                      18779     +117     
Files Changed Coverage
/client/service-container-chain/src/spawner.rs 40.94% (-3.50%)
/container-chains/nodes/frontier/src/command.rs 18.02% (-0.11%)
/container-chains/nodes/simple/src/command.rs 17.79% (-0.11%)
/node/src/service.rs 15.54% (-0.02%)

Coverage generated Fri Nov 15 10:35:18 UTC 2024

@girazoki
Copy link
Collaborator

When the node starts, it will check the container folders and delete all of them except the ones it is assigned to as a collator.

What happens if I stop it while it is syncing a chain (2000) but is assigned to another one (2001), then I boot it up again and we are still in the same situation? would I remove 2000?

Copy link
Collaborator

@girazoki girazoki left a comment

Choose a reason for hiding this comment

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

looks good from a code perspective!

@tmpolaczyk
Copy link
Contributor Author

What happens if I stop it while it is syncing a chain (2000) but is assigned to another one (2001), then I boot it up again and we are still in the same situation? would I remove 2000?

"assigned" means "current or next", so obviously it won't be removed

Copy link
Contributor

@ParthDesai ParthDesai left a comment

Choose a reason for hiding this comment

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

Code looks good.

@tmpolaczyk tmpolaczyk added B5-clientnoteworthy Changes should be mentioned in any downstream projects' release notes breaking Needs to be mentioned in breaking changes D3-trivial PR contains trivial changes in a runtime directory that do not require an audit labels Nov 15, 2024
@tmpolaczyk tmpolaczyk merged commit abfd360 into master Nov 15, 2024
42 checks passed
@tmpolaczyk tmpolaczyk deleted the tomasz-db-folder-cleanup branch November 15, 2024 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B5-clientnoteworthy Changes should be mentioned in any downstream projects' release notes breaking Needs to be mentioned in breaking changes D3-trivial PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants