registry/internal/database
Repository files (latest commit first)
Filename Latest commit message Latest commit date
adam jones 747ad310bb
Fix atomic latest version update to prevent missing isLatest flags (#530)
## Summary
Fixes a race condition where a server could have no version marked as
`isLatest` if the database operations failed independently.

## Changes
- **CreateServer signature**: Now accepts `oldLatestVersionID` parameter
to atomically unmark previous latest version
- **PostgreSQL implementation**: Uses a transaction to ensure UPDATE
(unmark old latest) and INSERT (create new version) happen atomically
- **Service layer**: Maintains `WithPublishLock` for concurrent
operation serialization
- **Two-level protection**: Advisory lock prevents races, transaction
ensures atomicity

## Test plan
- [x] Existing race condition tests pass
- [x] Integration tests pass
- [x] Unit tests pass

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-24 18:27:36 +01:00
..
migrations Fix race conditions in concurrent server publishing (#528) 2025-09-22 12:16:05 +01:00
database.go Fix atomic latest version update to prevent missing isLatest flags (#530) 2025-09-24 18:27:36 +01:00
migrate.go fix: use path.Join instead of filepath.Join for embedded migrations (#338) 2025-09-02 14:51:23 +01:00
postgres.go Fix atomic latest version update to prevent missing isLatest flags (#530) 2025-09-24 18:27:36 +01:00
testutil.go Fix atomic latest version update to prevent missing isLatest flags (#530) 2025-09-24 18:27:36 +01:00