indexReadyBlobs indexes blobs that have been recently marked as ready to be reindexed, after the blobs they depend on eventually were indexed.
(ctx context.Context)
| 121 | // indexReadyBlobs indexes blobs that have been recently marked as ready to be |
| 122 | // reindexed, after the blobs they depend on eventually were indexed. |
| 123 | func (ix *Index) indexReadyBlobs(ctx context.Context) { |
| 124 | defer ix.reindexWg.Done() |
| 125 | |
| 126 | popReadyReindex := func() (blob.Ref, bool) { |
| 127 | ix.Lock() |
| 128 | defer ix.Unlock() |
| 129 | |
| 130 | if len(ix.readyReindex) == 0 { |
| 131 | return blob.Ref{}, false |
| 132 | } |
| 133 | var br blob.Ref |
| 134 | for br = range ix.readyReindex { |
| 135 | break |
| 136 | } |
| 137 | delete(ix.readyReindex, br) |
| 138 | |
| 139 | return br, true |
| 140 | } |
| 141 | |
| 142 | failed := make(map[blob.Ref]bool) |
| 143 | for br, ok := popReadyReindex(); ok; br, ok = popReadyReindex() { |
| 144 | if err := ix.indexBlob(ctx, br); err != nil { |
| 145 | log.Printf("out-of-order indexBlob(%v) = %v", br, err) |
| 146 | failed[br] = true |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | ix.Lock() |
| 151 | defer ix.Unlock() |
| 152 | for br := range failed { |
| 153 | ix.readyReindex[br] = true |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | // noteBlobIndexed checks if the recent indexing of br now allows the blobs that |
| 158 | // were depending on br, to be indexed in turn. If yes, they're reindexed |