Skip to content

fix: prevent race condition in PostgreSQL setup#147

Open
Gustaf-Larsson wants to merge 8 commits intoBookBeat:masterfrom
Gustaf-Larsson:PostgresSetup
Open

fix: prevent race condition in PostgreSQL setup#147
Gustaf-Larsson wants to merge 8 commits intoBookBeat:masterfrom
Gustaf-Larsson:PostgresSetup

Conversation

@Gustaf-Larsson
Copy link
Copy Markdown

  • Added a semaphore to prevent setup race conditions
  • Wrapped each channel setup in a transaction to ensure atomicity

@aurora-codereview
Copy link
Copy Markdown

aurora-codereview Bot commented May 26, 2025

[bb-code-review]

# PR Review 🚀

- The usage of a semaphore to serialize the queue and subscription setup is straightforward and effective.
- Wrapping SQL commands in a transaction via an NpgsqlBatch ensures atomicity, reducing the risk of race conditions.
- Nice abstraction for creating batch commands; it improves maintainability by consolidating command creation.
- The added error handling with try/catch blocks and proper transaction rollback increases robustness.
- Overall, the changes address the race condition issue and improve setup reliability.

Great job! 👍


try
{
await createSchema.ExecuteNonQueryAsync().ConfigureAwait(false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tycker vi ska köra alla dessa i ett batch-kommando. En round trip till db

}
finally
{
Semaphore.Release();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

kör csharpier, whitespace här efter

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 4, 2025

<PackageIcon>knighbus-64.png</PackageIcon>
<RepositoryUrl>https://github.com/BookBeat/knightbus</RepositoryUrl>
<Version>2.1.0</Version>
<Version>2.2.0</Version>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

mergade en grej före, får ändra till 2.3.0 här

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