Skip to content

Fix changeset file race condition#63

Merged
raulgomis merged 6 commits intomasterfrom
fix/changeset-file-race-condition
Jul 23, 2025
Merged

Fix changeset file race condition#63
raulgomis merged 6 commits intomasterfrom
fix/changeset-file-race-condition

Conversation

@raulgomis
Copy link
Owner

Refactor create_changeset to prevent race conditions during file creation.

The previous create_changeset method was vulnerable to race conditions due to a check-then-create pattern (os.path.isfile then open). This PR fixes it by using open(..., 'x') for atomic, exclusive file creation within a retry loop to handle potential filename collisions. The redundant os.makedirs call was also removed as directory existence is ensured by the constructor.

cursoragent and others added 6 commits July 20, 2025 00:14
- Replace check-then-create logic with atomic file creation using 'x' mode
- Add retry loop with FileExistsError handling for collision recovery
- Ensure next-release directory exists with os.makedirs
- Prevents race conditions in concurrent environments
The next_release_path directory is already created in the constructor,
making the os.makedirs call in create_changeset redundant and inefficient.
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
* Add test for concurrent changeset creation race condition

Co-authored-by: raulgomis <raulgomis@gmail.com>

* Add test for changeset file creation race condition

Co-authored-by: raulgomis <raulgomis@gmail.com>

* Fix race condition in changeset file creation

Co-authored-by: raulgomis <raulgomis@gmail.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
@raulgomis raulgomis self-assigned this Jul 23, 2025
@raulgomis raulgomis merged commit e98bb0f into master Jul 23, 2025
5 checks passed
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.

2 participants