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

core/rawdb: fsync head data file before closing it #1399

Merged
merged 2 commits into from
Jan 14, 2023
Merged

core/rawdb: fsync head data file before closing it #1399

merged 2 commits into from
Jan 14, 2023

Conversation

ucwong
Copy link
Member

@ucwong ucwong commented Jan 14, 2023

This PR fixes an issue which might result in data lost in freezer.

Whenever mutation happens in freezer, all data will be written into head data file and it will be rotated with a new one in case the size of file reaches the threshold.

Theoretically, the rotated old data file should be fsync'd to prevent data loss. In freezer.Sync function, we only fsync: (1) index file (2) meta file and (3) head data file. So this PR forcibly fsync the head data file if mutation happens in the boundary of data file.

rjl493456442 and others added 2 commits January 14, 2023 02:31
This PR fixes an issue which might result in data lost in freezer.

Whenever mutation happens in freezer, all data will be written into head data file
and it will be rotated with a new one in case the size of file reaches the threshold.

Theoretically, the rotated old data file should be fsync'd to prevent data loss.
In freezer.Sync function, we only fsync: (1) index file (2) meta file and (3) head
data file. So this PR forcibly fsync the head data file if mutation happens in the
boundary of data file.
@codecov
Copy link

codecov bot commented Jan 14, 2023

Codecov Report

Merging #1399 (04f1d74) into master (d85b8f2) will decrease coverage by 0.05%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1399      +/-   ##
==========================================
- Coverage   51.76%   51.71%   -0.06%     
==========================================
  Files         464      464              
  Lines       58390    58392       +2     
==========================================
- Hits        30226    30197      -29     
- Misses      25875    25902      +27     
- Partials     2289     2293       +4     
Impacted Files Coverage Δ
core/rawdb/freezer_table.go 74.89% <0.00%> (-0.31%) ⬇️
core/rawdb/chain_freezer.go 16.96% <100.00%> (-4.25%) ⬇️
core/rawdb/chain_iterator.go 58.65% <0.00%> (-3.36%) ⬇️
p2p/enode/nodedb.go 74.46% <0.00%> (-2.56%) ⬇️
core/rawdb/freezer_batch.go 81.63% <0.00%> (-2.05%) ⬇️
ctxc/filters/api.go 50.00% <0.00%> (-1.34%) ⬇️
ctxc/sync.go 60.00% <0.00%> (-1.30%) ⬇️
whisper/whisperv6/whisper.go 54.01% <0.00%> (-1.20%) ⬇️
rpc/client.go 85.43% <0.00%> (-1.00%) ⬇️
... and 11 more

@ucwong ucwong merged commit 1694c70 into master Jan 14, 2023
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.

None yet

2 participants