Repository navigation
Fix corruption on restore - #11378
Conversation
76f1208 to
96dc31a
Compare
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 41d11d4e3394df04b1e476dc9fc97482fa76ede2 and 739a120. 📒 Files selected for processing (20)
📝 WalkthroughWalkthroughThis PR replaces the project schema version constants with Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant ProjectFileIO
participant DBConnection
participant SQLite
ProjectFileIO->>DBConnection: TransactionMutex()
ProjectFileIO->>SQLite: CheckVersion() / UpgradeSchema()
ProjectFileIO->>SQLite: WriteDoc() inserts project_history
ProjectFileIO->>SQLite: LoadProject() validates read-only and decode state
DBConnection->>SQLite: WAL checkpoint on close
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Warning Review ran into problems🔥 ProblemsLinked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
96dc31a to
64073d5
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: bff679ec-a149-44a2-85f2-eaa88bebcad1
📥 Commits
Reviewing files that changed from the base of the PR and between 655cbaa and 96dc31a1ab4e726d1c441474524ff33d89d3964b.
📒 Files selected for processing (8)
au3/libraries/au3-project-file-io/DBConnection.cppau3/libraries/au3-project-file-io/DBConnection.hau3/libraries/au3-project-file-io/ProjectFileIO.cppau3/libraries/au3-project-file-io/SqliteSampleBlock.cppau3/libraries/au3-project/ProjectFormatVersion.cppau3/libraries/au3-project/ProjectFormatVersion.hau3/libraries/au3-wave-track/Sequence.cppsrc/au3wrap/internal/au3project.cpp
64073d5 to
c7745cb
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: e2880b8e-4a5c-4135-be3b-970ed40e561a
📥 Commits
Reviewing files that changed from the base of the PR and between 64073d5c59b7a95c214ff9a75a692fb4fd60bf11 and c7745cb2276a1b150aec220c74662014507d585a.
📒 Files selected for processing (20)
au3/libraries/au3-project-file-io/DBConnection.cppau3/libraries/au3-project-file-io/DBConnection.hau3/libraries/au3-project-file-io/ProjectFileIO.cppau3/libraries/au3-project-file-io/SqliteSampleBlock.cppau3/libraries/au3-project/ProjectFormatVersion.cppau3/libraries/au3-project/ProjectFormatVersion.hau3/libraries/au3-wave-track/Sequence.cppsrc/au3wrap/internal/au3project.cppsrc/project/tests/audacityproject_tests.cppsrc/project/tests/data/empty.aup4src/project/tests/data/legacy_schema.aup4src/project/tests/data/test.aup4src/project/tests/realtimeeffectspersistence_tests.cppsrc/project/tests/testtools.hsrc/projectscene/tests/data/test.aup4src/trackedit/tests/au3interactiontestbase.hsrc/trackedit/tests/au3trackeditclipboard_tests.cppsrc/trackedit/tests/data/empty.aup4src/trackedit/tests/data/test.aup4src/trackedit/tests/data/testClipboard.aup4
✅ Files skipped from review due to trivial changes (2)
- src/project/tests/testtools.h
- src/project/tests/realtimeeffectspersistence_tests.cpp
🚧 Files skipped from review as they are similar to previous changes (8)
- au3/libraries/au3-project-file-io/DBConnection.h
- au3/libraries/au3-project-file-io/SqliteSampleBlock.cpp
- au3/libraries/au3-project/ProjectFormatVersion.h
- au3/libraries/au3-project-file-io/DBConnection.cpp
- src/au3wrap/internal/au3project.cpp
- au3/libraries/au3-project/ProjectFormatVersion.cpp
- au3/libraries/au3-wave-track/Sequence.cpp
- au3/libraries/au3-project-file-io/ProjectFileIO.cpp
4e611c8 to
41d11d4
Compare
When opening a dirty project the loaded doc is an "autosave" that the user could reject and rollback to the last saved one. If we delete orphans now we may delete blocks that are referenced by the saved project, and this will cause a corruption: audacity#11359 Orphans will be removed on close anyway
NOTE: This is a speculation, and might be not the case. A scenario: - AudioThread/: User is recording an audio, new Block audacity#500 is created - MainThread: starts autosaving, updates project doc and opens TransactionScope - AudioThread: New audio block 501 gets into block list, it gets into the current transaction, and AudioThread thinks it is saved - MainThread: gets an error (out of disk?), and Transaction is rolled back, including block 501 - Sequence still holds reference to block 501, even though it was never stored This mutex prevents simultaneous doc and sample write to the database
Also explicitly checkpoint on close
Length value is used during project recovery only, not used during normal operations
41d11d4 to
739a120
Compare
When opening a dirty project the loaded doc is an "autosave" that the user could reject and rollback to the last saved one. If we delete orphans now we may delete blocks that are referenced by the saved project, and this will cause a corruption: audacity#11359 Orphans will be removed on close anyway Backport of ac65627 (audacity#11378)
NOTE: This is a speculation, and might be not the case. A scenario: - AudioThread/: User is recording an audio, new Block audacity#500 is created - MainThread: starts autosaving, updates project doc and opens TransactionScope - AudioThread: New audio block 501 gets into block list, it gets into the current transaction, and AudioThread thinks it is saved - MainThread: gets an error (out of disk?), and Transaction is rolled back, including block 501 - Sequence still holds reference to block 501, even though it was never stored This mutex prevents simultaneous doc and sample write to the database Backport of 8890bb5 (audacity#11378)
Also explicitly checkpoint on close Backport of 00479c0 (audacity#11378)
Length value is used during project recovery only, not used during normal operations Backport of aacedf2 (audacity#11378)
When opening a dirty project the loaded doc is an "autosave" that the user could reject and rollback to the last saved one. If we delete orphans now we may delete blocks that are referenced by the saved project, and this will cause a corruption: audacity#11359 Orphans will be removed on close anyway Backport of ac65627 (audacity#11378)
NOTE: This is a speculation, and might be not the case. A scenario: - AudioThread/: User is recording an audio, new Block audacity#500 is created - MainThread: starts autosaving, updates project doc and opens TransactionScope - AudioThread: New audio block 501 gets into block list, it gets into the current transaction, and AudioThread thinks it is saved - MainThread: gets an error (out of disk?), and Transaction is rolled back, including block 501 - Sequence still holds reference to block 501, even though it was never stored This mutex prevents simultaneous doc and sample write to the database Backport of 8890bb5 (audacity#11378)
Also explicitly checkpoint on close Backport of 00479c0 (audacity#11378)
Length value is used during project recovery only, not used during normal operations Backport of aacedf2 (audacity#11378)
This may resolve these issues, but we can't reproduce them. We will keep the issues open for now to improve discoverability if more reports come in: - #1754 - #11359 - #11419 Might fix: #8319, #11244 This pr is a backport of #11378 Changes: * when closing a recovered unsaved project we should drop autosave * there was a tiny but possible corruption when the disk is full * there was a possible data loss on close if, for example, an external drive was unplugged immediately after closing the project * when disk went full, the checkpointing was stopped, so on close wal file was left unmerged * For better recoverability, a length field for each waveblock was added - [x] I signed [CLA](https://www.audacityteam.org/cla/) - [x] The title of the pull request describes an issue it addresses - [x] If changes are extensive, then there is a sequence of easily reviewable commits - [x] Each commit's message describes its purpose and effects - [x] There are no behavior changes unnecessary for the stated purpose of the PR Recommended: - [ ] Each commit compiles and runs on my machine without known undesirable changes of behavior QA: - [ ] Testflow test cases have been run
Resolves: #11359
0e223066 - fixes the corruption as described in #11359, the rest is additional protection and recoverability improvements
For better recoverability, was added project journal with up to 10 snapshots and a length field for each waveblock
Recommended:
QA: