Skip to content

Commit aec4776

Browse files
authored
Merge pull request #243 from frankhommers/features/lower-loglevel-serialization-failure-when-locking
Changed serialization failure when acquiring lock to debug log level
2 parents 3a5527f + 55e7806 commit aec4776

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Hangfire.PostgreSql/PostgreSqlDistributedLock.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using System.Threading;
2626
using Dapper;
2727
using Hangfire.Logging;
28+
using Npgsql;
2829

2930
namespace Hangfire.PostgreSql
3031
{
@@ -34,7 +35,8 @@ public sealed class PostgreSqlDistributedLock
3435

3536
private static void Log(string resource, string message, Exception ex)
3637
{
37-
_logger.WarnException($"{resource}: {message}", ex);
38+
bool isConcurrencyError = ex is PostgresException { SqlState: PostgresErrorCodes.SerializationFailure };
39+
_logger.Log(isConcurrencyError ? LogLevel.Trace : LogLevel.Warn, () => $"{resource}: {message}", ex);
3840
}
3941

4042
internal static void Acquire(IDbConnection connection, string resource, TimeSpan timeout, PostgreSqlStorageOptions options)

0 commit comments

Comments
 (0)