Changed to using atomics as mutex was causing deadlock

This commit is contained in:
2025-02-17 23:14:13 +11:00
parent 19f26d62a3
commit 556c93fc49
3 changed files with 96 additions and 22 deletions

View File

@@ -25,13 +25,12 @@ func WithTransaction(
),
) {
// Create a cancellable context from the request context
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)
ctx, cancel := context.WithTimeout(r.Context(), 2*time.Second)
defer cancel()
// Start the transaction
tx, err := conn.Begin(ctx)
if err != nil {
tx.Rollback()
logger.Warn().Err(err).Msg("Request failed to start a transaction")
w.WriteHeader(http.StatusServiceUnavailable)
page.Error(