Skip to content

Commit

Permalink
use select pg_advisory_xact_lock to serialize access to message table…
Browse files Browse the repository at this point in the history
… creation
  • Loading branch information
lsfera committed Jul 23, 2024
1 parent 49408fa commit 376d748
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Blumchen/Database/Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ private static async Task Execute(
CancellationToken ct)
{
await using var command = dataSource.CreateCommand(sql);
await command.ExecuteNonQueryAsync(ct).ConfigureAwait(false);
await command.ExecuteNonQueryAsync(ct);
}

public static async Task EnsureTableExists(this NpgsqlDataSource dataSource, TableDescriptorBuilder.MessageTable tableDescriptor, CancellationToken ct)
=> await dataSource.Execute(tableDescriptor.ToString(), ct).ConfigureAwait(false);
=> await dataSource.Execute(string.Concat("select pg_advisory_xact_lock(12345);", tableDescriptor), ct).ConfigureAwait(false);

public static async Task<bool> Exists(
this NpgsqlDataSource dataSource,
Expand Down

0 comments on commit 376d748

Please sign in to comment.