-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the item only if it exists in the cache #4117
Conversation
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #4117 +/- ##
==========================================
+ Coverage 58.98% 59.05% +0.07%
==========================================
Files 618 621 +3
Lines 52708 53091 +383
==========================================
+ Hits 31088 31353 +265
- Misses 19140 19239 +99
- Partials 2480 2499 +19
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Signed-off-by: Kevin Su <[email protected]>
Updates:
If the Item is added back to the cache after deletion, worker will run forever.
|
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
flytestdlib/cache/auto_refresh.go
Outdated
item, ok := w.lruMap.Get(itemID) | ||
if !ok { | ||
logger.Debugf(ctx, "item with id [%v] not found in cache", itemID) | ||
t.Stop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't stop the timer here, should we? just log and continue? the stop should happen after sync is called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated it
newBatch = append(newBatch, b) | ||
} | ||
|
||
updatedBatch, err := w.syncCb(ctx, newBatch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a check for if the len(newBatch) == 0, we don't need to sync at that point...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated it
w.lock.Lock() | ||
defer w.lock.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to avoid locking the entire dataset for these operations... any reason to?
ok = w.lruMap.Contains(id) | ||
if ok { | ||
w.lruMap.Add(id, item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only update if it's already there, what if it has been evicted since?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't check if it exist in the cache, we might have this scenario.
worker1
removes item from the caches -> worker2
adds the item to cache again. (workerqueue can have duplicate item)
If we don't use lock, we might have this scenario.
- w.toDelete.Remove (worker 1)
- w.lruMap.Contains(id) (woker 2)
- w.lruMap.Remove(key) (woker 1)
- w.lruMap.Add(id, item) (woker 2) # we add item back to the cache again.
Signed-off-by: Kevin Su <[email protected]>
TL;DR
I found that Propeller keeps sending the request to the agent even workflow is done.
The work queue only has unique items, so we add
itemID
to it. The workers won't process the item again after the task is done.Before:
After:
100 workflows, each has 100 tasks.
Before:
After:
Type
Are all requirements met?
Complete description
^^^
Tracking Issue
NA
Follow-up issue
NA