perf(delivery): stop re-reading hard links to verify them
Deploy / deploy (push) Successful in 6m25s
Deploy / deploy (push) Successful in 6m25s
A 25-shot episode took about an hour to package when the linking itself is instant. All of it was verification: every delivered file was read back and hashed, and at ~100 MB/s over SMB one 2.8 GB shot costs 30 s. Re-hashing a hard link cannot disagree with validation. The entry is a second name for the same data, so it re-reads the exact bytes that were already hashed — half an hour per episode to prove something that cannot be false. Verification is now proportional to what was actually done: copies are read back in full, links carry over the validation-time digest. Linking has one gap hashing covered incidentally: a source changed after it passed QC, which a link would carry faithfully. Source timestamps are now checked against the export's validation time, which costs a stat per file rather than a full read. "verifyMode": "always-hash" restores unconditional read-back for a production that requires it. Worker 1.3.0. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -123,17 +123,80 @@ public class DeliveryStageTests : IDisposable
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ChecksumMismatchFailsTheItem()
|
||||
public async Task ChecksumMismatchFailsACopiedItem()
|
||||
{
|
||||
WriteFrames(3);
|
||||
var result = await NewStage().RunAsync(new ClaimedJob { Id = "job1" },
|
||||
Manifest(checksum: "deadbeefdeadbeef"), "machine1", CancellationToken.None, CancellationToken.None);
|
||||
var manifest = Manifest(checksum: "deadbeefdeadbeef", copyMode: "always-copy");
|
||||
var result = await NewStage().RunAsync(new ClaimedJob { Id = "job1" }, manifest, "machine1",
|
||||
CancellationToken.None, CancellationToken.None);
|
||||
|
||||
Assert.False(result.Ok);
|
||||
Assert.Equal("FAILED", result.Items[0].Status);
|
||||
Assert.Contains("Checksum mismatch", result.Items[0].ErrorMessage!);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task HardLinkedItemsAreNotReadBack()
|
||||
{
|
||||
// A hard link is the same data as the source, so re-hashing it re-reads
|
||||
// the exact bytes validation already hashed — half an hour per episode
|
||||
// over SMB to prove something that cannot be false. A deliberately wrong
|
||||
// recorded checksum is therefore not consulted on the linked path, and
|
||||
// the validation-time digest carries over unchanged.
|
||||
WriteFrames(3);
|
||||
var result = await NewStage().RunAsync(new ClaimedJob { Id = "job1" },
|
||||
Manifest(checksum: "deadbeefdeadbeef"), "machine1", CancellationToken.None, CancellationToken.None);
|
||||
|
||||
Assert.True(result.Ok);
|
||||
Assert.Equal("VERIFIED", result.Items[0].Status);
|
||||
Assert.Equal("hardlink", result.Items[0].LinkMode);
|
||||
Assert.Equal("deadbeefdeadbeef", result.Items[0].Checksum);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AlwaysHashForcesReadBackEvenWhenLinked()
|
||||
{
|
||||
WriteFrames(3);
|
||||
var manifest = Manifest(checksum: "deadbeefdeadbeef");
|
||||
manifest.VerifyMode = "always-hash";
|
||||
var result = await NewStage().RunAsync(new ClaimedJob { Id = "job1" }, manifest, "machine1",
|
||||
CancellationToken.None, CancellationToken.None);
|
||||
|
||||
Assert.False(result.Ok);
|
||||
Assert.Contains("Checksum mismatch", result.Items[0].ErrorMessage!);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SourceTouchedAfterValidationFailsTheLinkedItem()
|
||||
{
|
||||
// The one thing linking cannot rule out: the source changing after it
|
||||
// passed QC. The link would faithfully carry the new bytes.
|
||||
WriteFrames(3);
|
||||
var manifest = Manifest();
|
||||
manifest.Items[0].ValidatedAt = DateTimeOffset.UtcNow.AddHours(-2);
|
||||
File.SetLastWriteTimeUtc(
|
||||
Path.Combine(_sourceDir, "SHOT_001_cmp_TT_v001.01002.exr"), DateTime.UtcNow);
|
||||
|
||||
var result = await NewStage().RunAsync(new ClaimedJob { Id = "job1" }, manifest, "machine1",
|
||||
CancellationToken.None, CancellationToken.None);
|
||||
|
||||
Assert.False(result.Ok);
|
||||
Assert.Contains("modified after validation", result.Items[0].ErrorMessage!);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UntouchedSourcesPassTheValidationTimestampCheck()
|
||||
{
|
||||
WriteFrames(3);
|
||||
var manifest = Manifest();
|
||||
manifest.Items[0].ValidatedAt = DateTimeOffset.UtcNow.AddHours(1);
|
||||
|
||||
var result = await NewStage().RunAsync(new ClaimedJob { Id = "job1" }, manifest, "machine1",
|
||||
CancellationToken.None, CancellationToken.None);
|
||||
|
||||
Assert.True(result.Ok);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FrameCountDriftSinceQcFailsTheItem()
|
||||
{
|
||||
@@ -163,14 +226,15 @@ public class DeliveryStageTests : IDisposable
|
||||
public async Task ChecksumMatchesTheValidationTimeDigestForIdenticalContent()
|
||||
{
|
||||
WriteFrames(3);
|
||||
var first = await NewStage().RunAsync(new ClaimedJob { Id = "job1" }, Manifest(), "machine1",
|
||||
CancellationToken.None, CancellationToken.None);
|
||||
var first = await NewStage().RunAsync(new ClaimedJob { Id = "job1" },
|
||||
Manifest(copyMode: "always-copy"), "machine1", CancellationToken.None, CancellationToken.None);
|
||||
|
||||
// Feeding the recorded digest back in must verify, which is exactly what
|
||||
// the delivery builder does against Export.checksum.
|
||||
// the delivery builder does against Export.checksum on the copy path.
|
||||
Directory.Delete(_packageDir, recursive: true);
|
||||
var second = await NewStage().RunAsync(new ClaimedJob { Id = "job1" },
|
||||
Manifest(checksum: first.Items[0].Checksum), "machine1", CancellationToken.None, CancellationToken.None);
|
||||
Manifest(checksum: first.Items[0].Checksum, copyMode: "always-copy"), "machine1",
|
||||
CancellationToken.None, CancellationToken.None);
|
||||
|
||||
Assert.True(second.Ok);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user