Repository navigation
index: preserve prior shards when publication fails - #1227
Conversation
keegancsmith
left a comment
There was a problem hiding this comment.
This makes sense if you only have 1 shard for your repo, but for other cases we now end up with inconsistent state.
If I am not mistaken if rename does fail, it likely fails for every rename we do since it will all be in the same dir. IE the rename failures should correlated by dir. But we should still think those cases through.
Additionally if we want to take rename failing more seriously, we probably want to do renames in a specific order rather than the random iteration we get from the artifactPaths dict. I think it would make sense to rename your 0th shard last. Care should also be taken to make sure the .meta file we end up with is consistent.
I would need to think more about this, but maybe with just this comment perfloop will cook up something good here :)
6e6db65 to
9041fb0
Compare
|
The update publishes data shards in deterministic descending shard-name order with shard zero last, then delta metadata in the same order, and stops at the first publication error. Each data rename is followed immediately by removal of its obsolete |
|
@keegancsmith: How did it do? :D |
|
The failure tests now cover growing indexes, delta metadata, and retries from empty or compound storage. Publication keeps shard zero last and stops at the first error; newly published data is cleaned up when no matching prior simple shard zero existed. The description now compares the failure states with main and states the cleanup and atomicity limits. |
keegancsmith
left a comment
There was a problem hiding this comment.
This addresses my earlier review, thanks. Remaining:
- The new early return when
IndexFilePathsfails leaks the temp files inartifactPathsand doesn't resetb.finishedShards. Please clean them up before returning. - Replace the suffix/length sort comparator with an explicit key (isMeta, isShardZero, shard number) and one line explaining it.
- 566 lines of tests for about 60 lines of logic is too much to maintain. Please cut it to one table-driven test (simple and compound × success, failure at shard 1, failure at shard 0) plus one delta case, and avoid the FIFO/symlink tricks where possible.
- Document in
Finish's comment that a failed publication can leave a mix of old and new shards until the retry.
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
9ec516d to
7835d92
Compare
|
The enumeration-error exit now removes staged files and clears |
keegancsmith
left a comment
There was a problem hiding this comment.
Thanks, this addresses all four points from my last review. LGTM.
Builder.Finishstops at the first rename or sidecar-removal error and retains it for repeated calls, instead of continuing into retirement that can delete prior data or hide the error. Publication uses explicit metadata, shard-zero, and numeric shard keys: data first, then delta metadata, with positive numbers ascending and shard zero last.For an existing simple index, a first rename failure leaves prior files unchanged. A middle failure keeps earlier replacements and later prior shards; a shard-zero failure keeps old zero. Previously, retirement could remove the failed replacement's prior shard. A directory-wide rename failure now stops without retiring the index.
Published data immediately loses its obsolete sidecar. If removing it fails, stale metadata can remain over the replacement. A delta metadata rename failure leaves earlier sidecar updates live and later ones, including zero, unchanged. Old shard-zero metadata keeps an updated commit eligible for reindexing.
Old-path enumeration errors clean staged files and clear
finishedShardsbefore returning. Without a prior simple shard zero, failed publication also attempts to remove newly published data so it cannot survive a smaller retry.Publication is not atomic: overwritten shards are not restored, and cleanup is best-effort.
Finishdocuments the mixed old/new state until retry.Go tests pass for publication failures, retirement, incremental-state decisions, delta metadata, and Git-indexing and end-to-end consumers.
index/builder_test.gocontains the six-case publication table and one delta failure case, without FIFO or symlink fixtures.Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart.