Skip to content

fix(storage): retain exact resources across interruption - #622

Merged
fishmingyu merged 1 commit into
mainfrom
fix/storage-publication-followup-v2
Aug 15, 2026
Merged

fix(storage): retain exact resources across interruption#622
fishmingyu merged 1 commit into
mainfrom
fix/storage-publication-followup-v2

Conversation

@fishmingyu

Copy link
Copy Markdown
Member

Summary

Harden the shared atomic-directory ownership path so native resources remain reachable and exactly cleanable when interruption lands around acquisition or cleanup.

This low-level fix is intentionally separate from #619 because it changes the common POSIX and Windows publication foundation and should land before the workspace API feature.

Changes

  • publish POSIX descriptor and Windows HANDLE records before native acquisition
  • route unwind through exact-record cleanup owners without sweeping unrelated resources
  • retain cleanup ownership across interrupted close and result handoff
  • preserve the first failure while reconciling cleanup failures
  • carry the same ownership protocol through Windows recursive scans
  • add adversarial acquisition, cleanup, identity, and cancellation regressions

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Performance improvement
  • Tests

Testing

  • Tests pass locally

  • Added new tests for the changes

  • Python 3.10, 3.12, and 3.14 atomic-directory tests: 256 passed, 10 skipped on each runtime

  • Python 3.14 direct-consumer storage suites: 512 passed, 10 skipped

  • local unit tier excluding the unavailable Docker sandbox: 5152 passed, 71 skipped, 190 deselected

  • Black, isort, flake8, py_compile, and git diff --check

Checklist

  • My code follows the project style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

@github-actions github-actions Bot added the type/test Test-related label Aug 13, 2026
@fishmingyu fishmingyu added the full-ci Run the hosted unit gate while a pull request is draft label Aug 13, 2026
@fishmingyu
fishmingyu force-pushed the fix/storage-publication-followup-v2 branch from e9fe251 to 0153d61 Compare August 13, 2026 23:30
Publish POSIX descriptor and Windows HANDLE records before native acquisition. Route failure cleanup through exact-record owners so interrupted cleanup cannot sweep unrelated resources, and carry the same ownership protocol through Windows tree scans while preserving the first failure.

This leaves the documented native-return/first-STORE and sentinel-generation limits unchanged.

Verified with Python 3.10, 3.12, and 3.14 atomic tests, Python 3.14 direct-consumer storage tests (512 passed, 10 skipped), and the local unit tier (5152 passed, 71 skipped, 190 deselected).
@fishmingyu
fishmingyu force-pushed the fix/storage-publication-followup-v2 branch from 0153d61 to cc74b6c Compare August 15, 2026 21:48
@fishmingyu
fishmingyu marked this pull request as ready for review August 15, 2026 21:52
@fishmingyu
fishmingyu merged commit bece048 into main Aug 15, 2026
16 checks passed
@fishmingyu
fishmingyu deleted the fix/storage-publication-followup-v2 branch August 15, 2026 21:56

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc74b6c186

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

except BaseException as error: # noqa: B036 - preserve exact local primary
context_error = error
failures.primary_error = error
failures.protect_pending_owners()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep owner protection inside the guarded finalizer

When the context body has already raised and a cancellation such as KeyboardInterrupt lands while this newly added call enters or executes, it escapes the except block before the bare raise. Although the finally retains context_error internally, locally_unwinding is then true, so the helper does not explicitly re-raise that original error and the cancellation becomes the outward exception instead. This is reproducible by making the first protect_pending_owners() invocation raise: a body ValueError is replaced by that interruption. Move this protection into the guarded finalizer path or otherwise ensure the stored body error remains primary.

Useful? React with 👍 / 👎.

Comment on lines +1239 to +1241
if record.identity is not None and observed_identity != record.identity:
record.descriptor = -1
return True

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve identity-change diagnostics in completion probes

When an owned descriptor has been closed and its numeric value reused for a different object before exact cleanup, this predicate clears the record and reports completion. Since protect_pending_owners() and the ordered runner invoke closed before the cleanup action, close_record() is then skipped and its publication descriptor ownership changed error is never retained; the mirrored Windows predicate has the same behavior. The previous cleanup path surfaced this mismatch as a diagnostic while still refusing to close the replacement, so leave identity mismatches incomplete long enough for _close_record() to report them rather than silently treating them as successful cleanup.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run the hosted unit gate while a pull request is draft type/test Test-related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant