mirror of https://github.com/apache/lucene.git
SOLR-9544: Give ObjectReleaseTracker more time for async closing objects
This commit is contained in:
parent
a41dd86e3c
commit
c55a14e198
|
@ -164,6 +164,9 @@ Other Changes
|
|||
* SOLR-5563: Move lots of SolrCloud logging from 'info' to 'debug' (janhoy, Alan
|
||||
Woodward)
|
||||
|
||||
* SOLR-9544: Allow ObjectReleaseTracker more time to check for asynchronously
|
||||
closing resources (Alan Woodward)
|
||||
|
||||
================== 6.2.1 ==================
|
||||
|
||||
Bug Fixes
|
||||
|
|
|
@ -29,12 +29,12 @@ public class TestObjectReleaseTracker extends LuceneTestCase {
|
|||
public void testObjectReleaseTracker() {
|
||||
ObjectReleaseTracker.track(new Object());
|
||||
ObjectReleaseTracker.release(new Object());
|
||||
assertNotNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty());
|
||||
assertNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty());
|
||||
assertNotNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty(1));
|
||||
assertNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty(1));
|
||||
Object obj = new Object();
|
||||
ObjectReleaseTracker.track(obj);
|
||||
ObjectReleaseTracker.release(obj);
|
||||
assertNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty());
|
||||
assertNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty(1));
|
||||
|
||||
Object obj1 = new Object();
|
||||
ObjectReleaseTracker.track(obj1);
|
||||
|
@ -46,7 +46,7 @@ public class TestObjectReleaseTracker extends LuceneTestCase {
|
|||
ObjectReleaseTracker.release(obj1);
|
||||
ObjectReleaseTracker.release(obj2);
|
||||
ObjectReleaseTracker.release(obj3);
|
||||
assertNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty());
|
||||
assertNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty(1));
|
||||
|
||||
ObjectReleaseTracker.track(obj1);
|
||||
ObjectReleaseTracker.track(obj2);
|
||||
|
@ -55,7 +55,7 @@ public class TestObjectReleaseTracker extends LuceneTestCase {
|
|||
ObjectReleaseTracker.release(obj1);
|
||||
ObjectReleaseTracker.release(obj2);
|
||||
// ObjectReleaseTracker.release(obj3);
|
||||
assertNotNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty());
|
||||
assertNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty());
|
||||
assertNotNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty(1));
|
||||
assertNull(ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty(1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Map.Entry;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -56,8 +57,18 @@ public class ObjectReleaseTracker {
|
|||
/**
|
||||
* @return null if ok else error message
|
||||
*/
|
||||
public static String clearObjectTrackerAndCheckEmpty() {
|
||||
String result = checkEmpty();
|
||||
public static String clearObjectTrackerAndCheckEmpty(int waitSeconds) {
|
||||
int retries = 0;
|
||||
String result;
|
||||
do {
|
||||
result = checkEmpty();
|
||||
if (result == null)
|
||||
break;
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
} catch (InterruptedException e) { break; }
|
||||
}
|
||||
while (retries++ < waitSeconds);
|
||||
|
||||
OBJECTS.clear();
|
||||
|
||||
|
@ -77,11 +88,9 @@ public class ObjectReleaseTracker {
|
|||
objects.add(entry.getKey().getClass().getSimpleName());
|
||||
}
|
||||
|
||||
error = "ObjectTracker found " + entries.size() + " object(s) that were not released!!! " + objects;
|
||||
|
||||
System.err.println(error);
|
||||
error = "ObjectTracker found " + entries.size() + " object(s) that were not released!!! " + objects + "\n";
|
||||
for (Entry<Object,String> entry : entries) {
|
||||
System.err.println(entry.getValue());
|
||||
error += entry.getValue() + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
|||
// if the tests passed, make sure everything was closed / released
|
||||
if (!RandomizedContext.current().getTargetClass().isAnnotationPresent(SuppressObjectReleaseTracker.class)) {
|
||||
endTrackingSearchers(120, false);
|
||||
String orr = ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty();
|
||||
String orr = ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty(30);
|
||||
assertNull(orr, orr);
|
||||
} else {
|
||||
endTrackingSearchers(15, false);
|
||||
|
|
Loading…
Reference in New Issue