Skip to content

Commit c348742

Browse files
committed
internal/postgres: remove the exclusive lock in upsertPath
As described in golang/go#75959, the lock in upsertPath causes a significant amount of contention during module inserts. Meanwhile, the upsertPaths method does not acquire a lock, and does not seem to cause deadlocks. We still don't understand the deadlocks avoided by this lock, but it seems that a low level of failed transactions due to deadlock may be preferable to the contention we're seeing currently. Let's experiment with removing the lock. For golang/go#75959 Change-Id: I2d577b426724010e96ffc8129ae469825fdcb938 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/718720 kokoro-CI: kokoro <[email protected]> Reviewed-by: Ethan Lee <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]>
1 parent 0d7e290 commit c348742

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

internal/postgres/path.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ func upsertPath(ctx context.Context, tx *database.DB, path string) (id int, err
8484
// fine.
8585
defer derrors.WrapStack(&err, "upsertPath(%q)", path)
8686

87-
if _, err := tx.Exec(ctx, `LOCK TABLE paths IN EXCLUSIVE MODE`); err != nil {
88-
return 0, err
89-
}
9087
err = tx.QueryRow(ctx,
9188
`INSERT INTO paths (path) VALUES ($1) ON CONFLICT DO NOTHING RETURNING id`,
9289
path).Scan(&id)

0 commit comments

Comments
 (0)