fabric icon indicating copy to clipboard operation
fabric copied to clipboard

Fix orphaned pvtdata missing entries from stale iterator during elg c…

Open Ady0333 opened this issue 9 months ago • 6 comments

Fix orphaned eligible missing private data entries during collection eligibility conversion

Type of change

  • Bug fix

Description

This PR fixes a race in private data storage that could silently create orphaned eligible missing data entries when a peer becomes newly eligible for a collection.

processCollElgEvents() converts ineligible missing data entries to eligible ones in batches. When the number of entries is large, it temporarily releases purgerLock between batches. During this unlock window, a purge cycle may delete expired missing data entries.

However, the conversion logic continued using a LevelDB iterator created before the lock was released. Because the iterator operates on a snapshot, it could still yield entries that were already deleted by the purger. Converting these stale entries recreates eligible prioritized missing data entries without corresponding expiry metadata, meaning they are never cleaned up by future purge cycles.

The fix re-creates the iterator after re-acquiring the lock so that only entries that still exist in the database are converted.

Additional details

  • The change is minimal and localized to the eligibility conversion path
  • No behavior changes outside processCollElgEvents()
  • All existing tests pass locally

Tested with: go test ./core/ledger/...

Release Note

Fixes an issue where private data eligibility conversion could create orphaned missing data entries that were never cleaned up by purge cycles.

Ady0333 avatar Feb 14 '26 21:02 Ady0333

@yacovm and @pfi79 . Plese review this pr once you guys have time. Thanks!!

Ady0333 avatar Feb 14 '26 21:02 Ady0333

We need a test that would show the importance of your changes.

pfi79 avatar Feb 14 '26 21:02 pfi79

Thanks for the feedback @pfi79 sir.

I agree. I’ll add a unit test in pvtdatastorage that reproduces the eligibility-conversion + purge overlap and asserts that no orphaned eligible missing data entries are created.

Ady0333 avatar Feb 14 '26 21:02 Ady0333

Hello @pfi79 , I am really really sorry for this much delay. There was some technical error with my Git Account due to which i was nt able to code.

For now as requested, I have added a test which would show importance of my changes.

Ady0333 avatar Mar 10 '26 22:03 Ady0333

@Ady0333 Will you still be working on this pr?

I remind you that in order for us to start considering pr, it is necessary that all conflicts are resolved and the pipeline is completely passed (in green).

pfi79 avatar Mar 20 '26 14:03 pfi79

@pfi79 Yes, i will be working on this pr till final. Not only this pr but all the PRs which i have opened, I will work on them till end. Apologies for any inconvience happened by me. I have solve the merged conflicts 👍

Ady0333 avatar Mar 20 '26 19:03 Ady0333