Xuanwo opened a new pull request, #8917: URL: https://github.com/apache/opendal/pull/8917
# Which issue does this PR close? None. Found during maintenance; no separate issue was filed. # Rationale for this change `core/services/persy` has three defects that reproduce against a real Persy datafile: - `PersyCore::set` always inserted a new record and replaced the `PersyId` stored in the index. The previous record stayed in the segment without any reference, so the datafile grew with every overwrite and old record pages were never reclaimed. - `PersyCore::delete` read the `PersyId` outside the write transaction. Concurrent `delete` calls could all observe the same id; after the first committed, the others failed in `persy`'s `prepare` with `RecordNotFound`, which mapped to `NotFound` even though delete must be idempotent. - `PersyBuilder::build` relied on `persy::OpenOptions::prepare_with`, which persy runs only while it creates a datafile. Opening an existing datafile with a new `segment`/`index` succeeded, but every later operation failed with `SegmentNotFound`/`IndexNotFound`, contradicting the "Will create if not exists" builder documentation. # What changes are included in this PR? - `PersyCore::set` reads the record id in the write transaction and updates that record in place. New paths still insert a record and put the index entry. - `PersyCore::delete` reads the record id in the same transaction that removes the record and the index entry, and returns `Ok(())` when the path is absent. - Write transactions are serialized by a mutex. persy takes its record and index locks only in `prepare`, so transactions that read the index concurrently can all act on the same stale entry and the losers fail with `RecordNotFound`. persy holds an exclusive file lock on the datafile, so this lock covers every writer. - `PersyBuilder::build` calls `PersyCore::init` after opening the datafile to create the configured segment and index when they are missing. - Regression tests in `core/services/persy/tests/transactions.rs` cover record replacement on overwrite, concurrent deletes, and reopening a datafile with a new segment and index. # Are there any user-facing changes? Overwrites no longer leave orphaned records in the datafile, concurrent deletes return `Ok(())`, and `PersyBuilder::segment`/`index` now create the configured schema on existing datafiles as documented. There are no API changes. # Breaking changes # AI Usage Statement - Harness: Pi - Model: DeepSeek V4.1 Flash - Effort: max - Role: Implemented the fixes and regression tests, and verified them against a real Persy datafile. Assumption: persy's exclusive file lock on the datafile makes an in-process write lock sufficient to serialize writers. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
