index: when reindexing fails due to missing blob, show some examples

This commit is contained in:
Brad Fitzpatrick 2021-10-24 19:36:16 -07:00
parent 0f53db21f7
commit 4fa9c80be0
1 changed files with 18 additions and 1 deletions

View File

@ -535,12 +535,29 @@ func (x *Index) Reindex() error {
x.RLock()
readyCount := len(x.readyReindex)
needed := len(x.needs)
var needSample bytes.Buffer
if needed > 0 {
n := 0
Sample:
for x, needs := range x.needs {
for _, need := range needs {
n++
if n == 10 {
break Sample
}
if n > 1 {
fmt.Fprintf(&needSample, ", ")
}
fmt.Fprintf(&needSample, "%v needs %v", x, need)
}
}
}
x.RUnlock()
if readyCount > 0 {
return fmt.Errorf("%d blobs were ready to reindex in out-of-order queue, but not yet ran", readyCount)
}
if needed > 0 {
return fmt.Errorf("%d blobs are still needed as dependencies", needed)
return fmt.Errorf("%d blobs are still needed as dependencies; a sample: %s", needed, needSample.Bytes())
}
nerrmu.Lock() // no need to unlock