Skip to content

Commit e6f805f

Browse files
committed
Merged PR 674680: Change proactive background status logic to correctly recognize skiped replic...
Change proactive background status logic to correctly recognize skiped replications Related work items: #1979555
1 parent 3fc4206 commit e6f805f

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

Public/Src/Cache/ContentStore/Distributed/Stores/DistributedContentStore.cs

+16-13
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using BuildXL.Cache.ContentStore.Interfaces.Stores;
2323
using BuildXL.Cache.ContentStore.Interfaces.Time;
2424
using BuildXL.Cache.ContentStore.Interfaces.Tracing;
25+
using BuildXL.Cache.ContentStore.Service.Grpc;
2526
using BuildXL.Cache.ContentStore.Stores;
2627
using BuildXL.Cache.ContentStore.Tracing;
2728
using BuildXL.Cache.ContentStore.Tracing.Internal;
@@ -399,7 +400,7 @@ IEnumerable<ContentEvictionInfo> getReplicableHashes()
399400
reason: CopyReason.ProactiveBackground);
400401

401402
wasPreviousCopyNeeded = true;
402-
switch (GetProactiveReplicationStatus(result))
403+
switch (GetProactiveBackgroundReplicationStatus(result))
403404
{
404405
case ProactivePushStatus.Success:
405406
CounterCollection[Counters.ProactiveReplication_Succeeded].Increment();
@@ -437,28 +438,30 @@ IEnumerable<ContentEvictionInfo> getReplicableHashes()
437438
counter: CounterCollection[Counters.ProactiveReplication]);
438439
}
439440

440-
private ProactivePushStatus GetProactiveReplicationStatus(ProactiveCopyResult result)
441+
private static ProactivePushStatus GetProactiveBackgroundReplicationStatus(ProactiveCopyResult result)
441442
{
442-
// When both Inside and Outside Copy fails, that is considered as failure
443-
if (result.InsideRingCopyResult?.Succeeded != true && result.OutsideRingCopyResult?.Succeeded != true)
444-
{
445-
return ProactivePushStatus.Error;
446-
}
443+
// For background replication, we only attempt outside-ring replication, so we only examine the outside ring result
444+
ProactivePushResult? outsideResult = result.OutsideRingCopyResult;
447445

448-
// Status is skipped when both Inside and Outside Copy was disabled or when Copy wasn't required in either ring
449-
if (result.Skipped)
446+
// Outside result being null indicates the that no push was attempted, ususally because content appears already sufficiently replicated
447+
if (outsideResult is null)
450448
{
451449
return ProactivePushStatus.Skipped;
452450
}
453451

454-
// Status is Rejected when both Inside and Outside Copy was rejected
455-
if (result.InsideRingCopyResult?.Rejected == true || result.OutsideRingCopyResult?.Rejected == true)
452+
// Test for rejected explicitly first, otherwise it will appear as success or error
453+
if (outsideResult.Rejected)
456454
{
457455
return ProactivePushStatus.Rejected;
458456
}
459457

460-
// All other cases are considered success
461-
return ProactivePushStatus.Success;
458+
if (outsideResult.Succeeded)
459+
{
460+
return ProactivePushStatus.Success;
461+
}
462+
463+
return ProactivePushStatus.Error;
464+
462465
}
463466

464467
/// <inheritdoc />

0 commit comments

Comments
 (0)