NIFI-15570: Keep track of Content Claims where the last Claim in a Re… by markap14 · Pull Request #10874 · apache/nifi

The truncate method doesn't verify that the claimant count is still 0 before truncating. If a clone operation increments the claimant count while the truncation task is mid-flight, we could truncate content that is still referenced. Isn't it a concern?

Wondering if we could have a race condition:

  1. TruncateClaims.truncateClaims() checks claim.isTruncationCandidate() and sees true
  2. A clone operation calls incrementClaimaintCount(), which sets truncationCandidate = false and increments the claimant count
  3. TruncateClaims.truncate() proceeds to truncate the file anyway, corrupting the data for the newly cloned FlowFile

Or maybe this scenario is not an option for some reasons that I missed?