internal/postgres: lock paths table on insert
internal/postgres: lock paths table on insert

Lock the paths table when we insert into it. That should address
deadlocks we see with this table, presumably because concurrent
transactions are inserting rows in different orders.

The lock mode is EXCLUSIVE, allowing readers but no other writers.
See https://www.postgresql.org/docs/11/explicit-locking.html.

The lock persists until the end of the transaction. There is no way to
unlock sooner. See https://www.postgresql.org/docs/11/sql-lock.html.

Change-Id: I2767f40c265b6c40581bca7512ea5cde7b2d3d42
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/300109
Trust: Jonathan Amsterdam <e3d3698b2ccd5955e4adf250d0785062d0f9018b@google.com>
Run-TryBot: Jonathan Amsterdam <e3d3698b2ccd5955e4adf250d0785062d0f9018b@google.com>
TryBot-Result: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>
Reviewed-by: Julie Qiu <8d32267b6b4884cf35adeaccde2b6857ae11aace@golang.org>

golang/pkgsite,golang/pkgsite,golang/pkgsite,golang/pkgsite