diff options
| author | Jonathan Amsterdam <jba@google.com> | 2020-10-28 07:23:47 -0400 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2020-10-28 13:54:53 +0000 |
| commit | c7dbd1a7e4c3ebc81482fc11bb31fcc632c9d7e2 (patch) | |
| tree | 9c85ea740140f3e1db77aeb3901aa9597657131e /internal/postgres/insert_module.go | |
| parent | 9ab53d6b28d75ec1fa0145577cec1c10256cae0b (diff) | |
| download | go-x-pkgsite-c7dbd1a7e4c3ebc81482fc11bb31fcc632c9d7e2.tar.xz | |
internal/postgres: drop locking messages when query logging is disabled
Avoids log clutter during tests.
Change-Id: I0591a27e8b390794a41e93cd2a4cb158033dbe9e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/265877
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'internal/postgres/insert_module.go')
| -rw-r--r-- | internal/postgres/insert_module.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/postgres/insert_module.go b/internal/postgres/insert_module.go index b87928a9..9d55a5b3 100644 --- a/internal/postgres/insert_module.go +++ b/internal/postgres/insert_module.go @@ -443,12 +443,16 @@ func lock(ctx context.Context, tx *database.DB, modulePath string) (err error) { hasher := fnv.New64() io.WriteString(hasher, modulePath) // Writing to a hash.Hash never returns an error. h := int64(hasher.Sum64()) - log.Debugf(ctx, "locking %s (%d) ...", modulePath, h) + if !database.QueryLoggingDisabled { + log.Debugf(ctx, "locking %s (%d) ...", modulePath, h) + } // See https://www.postgresql.org/docs/11/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS. if _, err := tx.Exec(ctx, `SELECT pg_advisory_xact_lock($1)`, h); err != nil { return err } - log.Debugf(ctx, "locking %s (%d) succeeded", modulePath, h) + if !database.QueryLoggingDisabled { + log.Debugf(ctx, "locking %s (%d) succeeded", modulePath, h) + } return nil } |
