added checks local lock state before DB insert in shared token selector#1483
added checks local lock state before DB insert in shared token selector#1483Horiodino wants to merge 1 commit intohyperledger-labs:mainfrom
Conversation
3f749a5 to
f2f477a
Compare
f2f477a to
7fe8b5a
Compare
|
Hi @Horiodino , thanks for submitting this. I'll review ASAP. A first comment though. A cache per selector might not be helpful because other selectors might end up choosing tokens already selected. I would investigate a more global locker instantiated at the manager level and passed to each selector. |
|
Hi @Horiodino , did you have time to look at my comment? |
7fe8b5a to
fbad5a3
Compare
|
Hey , i have moved the implementation from a per-selector cache to a shared local lock tracker,different selectors are aware of tokens already locked within the same replica, could you review? , i would fix the conflicts asap if it looks good. |
There was a problem hiding this comment.
why don't we pass an instance of locker that embeds the behavior of your localTokenLockTracker directly? This would reduce the code impact.
There was a problem hiding this comment.
good point,i kept them separate because the Locker represents the shared/external locking mechanism, while the localTokenLockTracker is strictly in-memory .
keeeping that split avoids coupling the Locker to local state and makes the behavior explicit, since not all Locker implementations are necessarily local-aware.
|
Hi @Horiodino , I left an initial comment. But, I also need you to run the benchmarks in Many thanks for your effort 🙏 |
|
Hi @Horiodino , any news? |
|
from the benchmark comparison I ran (current branch vs baseline): sherdlock slowdown (time) it checks a local in-memory lock map,then also checks shared local lock state,this happens in a loop. |
Signed-off-by: Praful <holiodin@gmail.com>
fbad5a3 to
dfce434
Compare
|
Hi @Horiodino , any progress on this PR? |
This PR fixes #886 by adding a local lock check before attempting DB lock insertion in the shared token selector.
The selector now tracks tokens already locked by the current replica and skips duplicate
TryLockcalls for the same token within the same selection cycle. The local lock state is cleared duringUnlockAll().This avoids unnecessary DB round trips and optimistic insert failures when duplicate tokens are returned by the iterator.