Large number of rolled back transactions on JPA/JDBC TokenStore #1475
Labels
Priority 2: Should
High priority. Ideally, these issues are part of the release they’re assigned to.
Status: Resolved
Use to signal that work on this issue is done.
Type: Enhancement
Use to signal an issue enhances an already existing feature of the project.
Milestone
With a large number of nodes running a certain tracking processor, each node will have 1 WorkerLauncher threads checking for segments to claim. It will iterate of each of the segments and do an attempt to claim that segment. Under normal circumstances, this process will fail most of the time, as segments are already claimed.
Problem:
The WorkerLauncher initiates a transaction within a loop to attempt to claim each available segment individually. Because segments are claimed, the TokenStore throws a UnableToClaimTokenException, causing the transaction to be rolled back. While the processor deals with the exception transparently, it causes a large number of transactions to start, and roll back.
Suggestions:
The TokenStore should expose a method that allows for more efficient implementations of the "attempt to claim a token" process. This implementation should check within the scope of a processor name, if any unclaimed or abandoned segments are available. If not, it simply returns an empty optional. If there is a segment available, it will claim and return the token for that segment.
This can be implemented as a default method, which does the iteration internally. An extra "tryFetchToken" method can be added that returns an Optional instead of throwing an exception when a claim fails.
The text was updated successfully, but these errors were encountered: