mirror of https://github.com/apache/lucene.git
SOLR-12412: Leak transaction log on tragic event
This commit is contained in:
parent
c9e3c456e3
commit
eada799f57
|
@ -188,6 +188,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
|
||||||
protected TransactionLog bufferTlog;
|
protected TransactionLog bufferTlog;
|
||||||
protected TransactionLog tlog;
|
protected TransactionLog tlog;
|
||||||
protected TransactionLog prevTlog;
|
protected TransactionLog prevTlog;
|
||||||
|
protected TransactionLog prevTlogOnPrecommit;
|
||||||
protected final Deque<TransactionLog> logs = new LinkedList<>(); // list of recent logs, newest first
|
protected final Deque<TransactionLog> logs = new LinkedList<>(); // list of recent logs, newest first
|
||||||
protected LinkedList<TransactionLog> newestLogsOnStartup = new LinkedList<>();
|
protected LinkedList<TransactionLog> newestLogsOnStartup = new LinkedList<>();
|
||||||
protected int numOldRecords; // number of records in the recent logs
|
protected int numOldRecords; // number of records in the recent logs
|
||||||
|
@ -810,6 +811,11 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
|
||||||
// since document additions can happen concurrently with commit, create
|
// since document additions can happen concurrently with commit, create
|
||||||
// a new transaction log first so that we know the old one is definitely
|
// a new transaction log first so that we know the old one is definitely
|
||||||
// in the index.
|
// in the index.
|
||||||
|
if (prevTlog != null) {
|
||||||
|
// postCommit for prevTlog is not called, may be the index is corrupted
|
||||||
|
// if we override prevTlog value, the correspond tlog will be leaked, close it first
|
||||||
|
postCommit(cmd);
|
||||||
|
}
|
||||||
prevTlog = tlog;
|
prevTlog = tlog;
|
||||||
tlog = null;
|
tlog = null;
|
||||||
id++;
|
id++;
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.apache.solr.common.cloud.ClusterStateUtil;
|
||||||
import org.apache.solr.common.cloud.DocCollection;
|
import org.apache.solr.common.cloud.DocCollection;
|
||||||
import org.apache.solr.common.cloud.Replica;
|
import org.apache.solr.common.cloud.Replica;
|
||||||
import org.apache.solr.common.cloud.Slice;
|
import org.apache.solr.common.cloud.Slice;
|
||||||
|
import org.apache.solr.common.util.ObjectReleaseTracker;
|
||||||
import org.apache.solr.core.CoreContainer;
|
import org.apache.solr.core.CoreContainer;
|
||||||
import org.apache.solr.core.DirectoryFactory;
|
import org.apache.solr.core.DirectoryFactory;
|
||||||
import org.apache.solr.core.MockDirectoryFactory;
|
import org.apache.solr.core.MockDirectoryFactory;
|
||||||
|
@ -181,15 +182,13 @@ public class LeaderTragicEventTest extends SolrCloudTestCase {
|
||||||
|
|
||||||
Replica oldLeader = corruptLeader(collection, new ArrayList<>());
|
Replica oldLeader = corruptLeader(collection, new ArrayList<>());
|
||||||
|
|
||||||
//TODO better way to test this
|
|
||||||
Thread.sleep(5000);
|
|
||||||
Replica leader = getCollectionState(collection).getSlice("shard1").getLeader();
|
|
||||||
assertEquals(leader.getName(), oldLeader.getName());
|
|
||||||
|
|
||||||
if (otherReplicaJetty != null) {
|
if (otherReplicaJetty != null) {
|
||||||
// won't be able to do anything here, since this replica can't recovery from the leader
|
|
||||||
otherReplicaJetty.start();
|
otherReplicaJetty.start();
|
||||||
}
|
}
|
||||||
|
//TODO better way to test this
|
||||||
|
Thread.sleep(2000);
|
||||||
|
Replica leader = getCollectionState(collection).getSlice("shard1").getLeader();
|
||||||
|
assertEquals(leader.getName(), oldLeader.getName());
|
||||||
} finally {
|
} finally {
|
||||||
CollectionAdminRequest.deleteCollection(collection).process(cluster.getSolrClient());
|
CollectionAdminRequest.deleteCollection(collection).process(cluster.getSolrClient());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue