Skip to content

Commit 2781000

Browse files
committed
Fix concurrent NpgsqlDataSource.Dispose and Bootstrap (#6116)
Fixes #6115 (cherry picked from commit 6f8971c)
1 parent 223d425 commit 2781000

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Npgsql/NpgsqlDataSource.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,10 @@ protected virtual void DisposeBase()
473473
}
474474

475475
_periodicPasswordProviderTimer?.Dispose();
476-
_setupMappingsSemaphore.Dispose();
477476
MetricsReporter.Dispose();
477+
// We do not dispose _setupMappingsSemaphore explicitly, leaving it to finalizer
478+
// Due to possible concurrent access, which might lead to deadlock
479+
// See issue #6115
478480

479481
Clear();
480482
}
@@ -508,8 +510,10 @@ protected virtual async ValueTask DisposeAsyncBase()
508510
#endif
509511
}
510512

511-
_setupMappingsSemaphore.Dispose();
512513
MetricsReporter.Dispose();
514+
// We do not dispose _setupMappingsSemaphore explicitly, leaving it to finalizer
515+
// Due to possible concurrent access, which might lead to deadlock
516+
// See issue #6115
513517

514518
// TODO: async Clear, #4499
515519
Clear();

0 commit comments

Comments
 (0)