feat: guarantee reservation consistency under concurrent transactions#11
Merged
heitorrsdev merged 2 commits intomainfrom Feb 27, 2026
Merged
Conversation
341a20d to
3d657cc
Compare
…eline chore: add default test time constant refactor: isolate user and barber factories responsabilites refactor: rename isUniqueViolation to isExclusionViolation chore: make pool max connections explicit refactor: expose Transaction and DrizzleClient types refactor: explicitly type createDatabase return value refactor: allow repositories to accept transactions via DrizzleClient test: create reservation factory for database seeding test: add barrier helper for concurrency tests test: prevent double booking under concurrent transactions fix: ensure CI uses ci-test Makefile target chore: remove .env file dependency and simplify CI environment handling chore: remove unused dotenv-cli dependency chore: remove unused environment files test: log concurrency results to debug CI chore: remove unused global Jest setup chore: define maxWorkers to 1 in jest config fix: close database pool after test suite
6731d7c to
001687b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR strengthens concurrency guarantees in the reservation system by introducing transactional repository support and validating database-level invariant enforcement under real concurrent execution.
It ensures that overlapping reservations are prevented at the PostgreSQL level via exclusion constraints and verifies this behavior through deterministic concurrency integration tests.
Additionally, it standardizes repository typing to support transactions cleanly and formalizes the project’s testing model in documentation.
What was done
DrizzleClientabstraction to allow repositories to operate with both root database instances and transactionsReservationConflictErrortesting.mddocumentation describing the testing strategy and invariant enforcement model.envfile dependency from Makefile targetsDATABASE_URLdotenv-cliusage in favor of native environment variable handling.envfilesmaxWorkers: 1to prevent concurrency issuesWhy
as any) and ensure strict typing with DrizzleNotes
EXCLUDE USING gistconstraints