Skip to content

Conversation

timvisee
Copy link
Member

@timvisee timvisee commented Mar 17, 2025

Tracked in: #6157
Depends on: #6169

If the last entry in the mappings file is partial, truncate the file.

It can happen if we crash during flush. We must truncate the file so that newly appended mappings don't get corrupted.

I don't particularly like the implementation, but the tools here are a bit limited. An alternative approach would require to load the full file in memory, or it would require to read over the file twice, which is why I implemented the current approach instead.

Tasks

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --all --all-features command?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@timvisee timvisee force-pushed the mutable-id-tracker-version-storage branch from 05172b4 to 1c38a5d Compare March 17, 2025 13:28
@timvisee timvisee force-pushed the mutable-id-tracker-truncate-partial-mapping branch from b0f0b13 to 4e20e69 Compare March 17, 2025 13:28
@timvisee timvisee mentioned this pull request Mar 17, 2025
9 tasks
@timvisee timvisee requested a review from coszio March 18, 2025 08:32
Base automatically changed from mutable-id-tracker-version-storage to dev March 18, 2025 10:18
@timvisee timvisee force-pushed the mutable-id-tracker-truncate-partial-mapping branch from 40c187d to 0ba670f Compare March 18, 2025 10:21

This comment was marked as off-topic.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@timvisee timvisee merged commit 2caa6e1 into dev Mar 19, 2025
17 checks passed
@timvisee timvisee deleted the mutable-id-tracker-truncate-partial-mapping branch March 19, 2025 09:39
timvisee added a commit that referenced this pull request Mar 21, 2025
…6173)

* Keep track of how many bytes are read, truncate mappings on last partial

* Rely on reader position to detect incomplete entry at the end

* Fix typo

* Handle edge case properly, don't truncate file if fully read

* minor fix

* Add test to assert operation size equals bytes read from stream

* Functions can be constant

* Fix some nitpicks

---------

Co-authored-by: generall <andrey@vasnetsov.com>
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.

3 participants