Skip to content
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

Potential Bug - Client should reset leaseDuration waiting time when recordVersionNumber noticed to change #94

Open
basilmusa opened this issue Nov 8, 2023 · 0 comments

Comments

@basilmusa
Copy link

basilmusa commented Nov 8, 2023

In the below source code in acquireLock method (source code link)

It is noticed that the else condition notices that the UUID changed in recordVersionNumber but it never resets the waiting period in variable millisecondsToWait.

This could have negative impact since the acquireLock is now waiting on something that it knows it will never acquire (unless ofcourse isReleased in DDB is set to true). So I think a fix should be applied here to extend the duration the acquire lock time has to wait by increasing the millisecondsToWait to allow the method to wait for the actual leaseDuration again by resetting it.

p.s. I work at Amazon, you can contact me on my username basabbas to discuss.

                        if (lockTryingToBeAcquired.getRecordVersionNumber().equals(existingLock.get().getRecordVersionNumber())) {
                            /* If the version numbers match, then we can acquire the lock, assuming it has already expired */
                            if (lockTryingToBeAcquired.isExpired()) {
                                return upsertAndMonitorExpiredLock(options, key, sortKey, deleteLockOnRelease, sessionMonitor, existingLock, newLockData, item,
                                    recordVersionNumber);
                            }
                        } else {
                            /*
                             * If the version number changed since we last queried the lock, then we need to update
                             * lockTryingToBeAcquired as the lock has been refreshed since we last checked
                             */
                            lockTryingToBeAcquired = existingLock.get();
                        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant