Skip to content

Conversation

atimin
Copy link
Member

@atimin atimin commented Aug 22, 2025

Closes #904

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • CHANGELOG.md has been updated (for bug fixes / features / docs)

What kind of change does this PR introduce?

Bug fix

What was changed?

The file cache is now responsible for synchronizing files with the disk to prevent data loss in the event of a power failure.
The File Cache synchronizes all files that are open for writing:

  1. Every 100 ms.
  2. When they are discarded from the cache.

Related issues

Does this PR introduce a breaking change?

No

Other information:

@atimin atimin marked this pull request as draft August 22, 2025 06:59
Copy link

codecov bot commented Aug 22, 2025

Codecov Report

❌ Patch coverage is 93.33333% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.34%. Comparing base (f700f6a) to head (17fef47).

Files with missing lines Patch % Lines
reductstore/src/core/file_cache.rs 93.05% 5 Missing ⚠️
@@            Coverage Diff             @@
##           stable     #909      +/-   ##
==========================================
- Coverage   95.36%   95.34%   -0.03%     
==========================================
  Files         167      167              
  Lines       10102    10159      +57     
==========================================
+ Hits         9634     9686      +52     
- Misses        468      473       +5     
Files with missing lines Coverage Δ
reductstore/src/core/cache.rs 100.00% <100.00%> (ø)
reductstore/src/core/file_cache.rs 95.36% <93.05%> (-2.58%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@atimin atimin changed the title 904 bug current block is not synced with disk until it is finished 1 Prevent data loot of unsynchronized files in case of power failure for unfinished blocks Aug 22, 2025
@atimin atimin changed the title Prevent data loot of unsynchronized files in case of power failure for unfinished blocks Prevent data lost of unsynchronized files in case of power failure for unfinished blocks Aug 22, 2025
@atimin atimin requested a review from Copilot August 22, 2025 09:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements file synchronization to prevent data loss during power failures for unfinished blocks. The solution adds periodic syncing functionality to the file cache to ensure data integrity.

  • Adds a background sync worker that periodically syncs open write files every 100ms
  • Implements sync-on-eviction for files being removed from the cache
  • Extends the cache with iterator functionality to support the sync operations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
reductstore/src/core/file_cache.rs Main implementation of sync worker, file sync logic, and cache eviction handling
reductstore/src/core/cache.rs Adds iterator support for the sync worker to iterate over cached files
CHANGELOG.md Documents the bug fix for preventing data loss during power failures

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

atimin and others added 2 commits August 22, 2025 11:48
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@atimin atimin marked this pull request as ready for review August 22, 2025 09:51
@atimin atimin merged commit 3dd6acd into stable Aug 22, 2025
4 of 23 checks passed
@atimin atimin deleted the 904-bug-current-block-is-not-synced-with-disk-until-it-is-finished-1 branch August 22, 2025 10:05
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