Skip to content

added checks local lock state before DB insert in shared token selector#1483

Open
Horiodino wants to merge 1 commit intohyperledger-labs:mainfrom
Horiodino:replica_local_check
Open

added checks local lock state before DB insert in shared token selector#1483
Horiodino wants to merge 1 commit intohyperledger-labs:mainfrom
Horiodino:replica_local_check

Conversation

@Horiodino
Copy link
Copy Markdown

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 TryLock calls for the same token within the same selection cycle. The local lock state is cleared during UnlockAll().
This avoids unnecessary DB round trips and optimistic insert failures when duplicate tokens are returned by the iterator.

@adecaro adecaro self-requested a review April 7, 2026 07:59
@adecaro adecaro self-assigned this Apr 7, 2026
@adecaro adecaro force-pushed the replica_local_check branch from 3f749a5 to f2f477a Compare April 7, 2026 08:00
@adecaro adecaro added this to the Q2/26 milestone Apr 7, 2026
@adecaro adecaro force-pushed the replica_local_check branch from f2f477a to 7fe8b5a Compare April 7, 2026 11:48
@adecaro
Copy link
Copy Markdown
Contributor

adecaro commented Apr 8, 2026

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.

@adecaro
Copy link
Copy Markdown
Contributor

adecaro commented Apr 10, 2026

Hi @Horiodino , did you have time to look at my comment?
Thanks 🙏

@Horiodino Horiodino force-pushed the replica_local_check branch from 7fe8b5a to fbad5a3 Compare April 11, 2026 07:16
@Horiodino
Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shared token selector: first check locally

2 participants