internal/frontend: don't log mismatch count error at limit
We've been logging an error if the importer count from
search_documents exceeds the number of rows from imports_unique, but
that didn't take into account the fact that we limit the number of
imports_unique rows.
So only log an error when we haven't exceeded that limit.
Also add more information to the log message for easier debugging.
Change-Id: Iaf39759edfd471c60441fdae2be38c139874be81
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/348792
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/frontend/imports.go b/internal/frontend/imports.go
index 66503c7..947275a 100644
--- a/internal/frontend/imports.go
+++ b/internal/frontend/imports.go
@@ -110,12 +110,12 @@
if err != nil {
return nil, err
}
- if numImportedBySearch > numImportedBy {
- // numImportedBySearch should never be greater than numImportedBy.
- //
- // If that happens, log an error so that we can debug, but continue
- // with generating the page fo the user.
- log.Errorf(ctx, "search_documents.num_imported_by > numImportedBy from imports unique, which shouldn't happen: %d", numImportedBySearch)
+ if numImportedBy < importedByLimit && numImportedBySearch > numImportedBy {
+ // Unless we hit the limit, numImportedBySearch should never be greater
+ // than numImportedBy. If that happens, log an error so that we can
+ // debug, but continue with generating the page fo the user.
+ log.Errorf(ctx, "pkg %q, module %q: search_documents.num_imported_by %d > numImportedBy %d from imports unique, which shouldn't happen",
+ pkgPath, modulePath, numImportedBySearch, numImportedBy)
}
if numImportedBy >= importedByLimit {