rishabhdaim commented on code in PR #2660:
URL: https://github.com/apache/jackrabbit-oak/pull/2660#discussion_r2667301982
##########
oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexCopier.java:
##########
@@ -363,28 +366,31 @@ public boolean isCopyInProgress(LocalIndexFile file) {
* @param timeoutMillis
*/
public void waitForCopyCompletion(LocalIndexFile file, long timeoutMillis)
{
- final Monitor.Guard notCopyingGuard = new
Monitor.Guard(copyCompletionMonitor) {
- @Override
- public boolean isSatisfied() {
- return !isCopyInProgress(file);
- }
- };
long localLength = file.actualSize();
long lastLocalLength = localLength;
boolean notCopying = !isCopyInProgress(file);
while (!notCopying) {
+ final long deadline = System.nanoTime() +
TimeUnit.MILLISECONDS.toNanos(timeoutMillis);
+ copyCompletionLock.lock();
Review Comment:
by following this logic, we ensure that we block for only an absolute time
in future.
On each inner-loop iteration you recompute `remaining = deadline -
System.nanoTime()`
This is to ensure that regardless of how many times the threads are woken,
we only wait for `timeoutMillis`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]