ArafatKhan2198 opened a new pull request, #12206:
URL: https://github.com/apache/ozone/pull/12206
## **What changes were proposed in this pull request?**
**What was going wrong**
1. The OBS and Legacy NSSummary sub-tasks cache each bucket's info to avoid
a DB read per event.
2. They dropped a cached entry only on a bucket delete event, assuming a
recreate always follows a delete.
3. That assumption breaks in two ways:
- A delete and recreate of the same bucket name in one OM flush reach
Recon as a single bucket update, so no delete event ever arrives.
- A rebuild runs on a separate task instance, and `NSSummaryTask` did
not override `init()`, so the live sub-tasks kept their caches.
4. The cache therefore still held the deleted bucket, with its old objectID.
5. Every later key of the recreated bucket was counted under the deleted
bucket's objectID.
6. `/namespace/summary` and `/namespace/du` read the summary of the bucket's
current objectID, so they silently under-reported the recreated bucket.
**The fix**
- Both sub-tasks now keep the cache in line with every bucket event: a put
or update refreshes a cached entry with the event's bucket info, a delete
removes it.
- `NSSummaryTask.init()` clears both caches. Recon already calls `init()` at
startup and after every successful rebuild.
**Why it is safe**
- Only cached buckets are refreshed, so the cache does not grow and no extra
DB read is added.
- Each sub-task owns its own cache on its own thread, and `init()` runs
between batches, so there is no race.
- A cleared cache only costs one lookup per bucket, and the lookup result is
already null-checked.
## **What is the link to the Apache JIRA**
https://issues.apache.org/jira/browse/HDDS-17049
## **How was this patch tested?**
- New
`TestNSSummaryTask.TestProcessBucketRecreate#testBucketCacheInvalidatedOnRecreateInOneFlush`
and `#testBucketCacheClearedOnInit`. Both fail without the change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]