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

Remove Lucene Precommit from PersistentCache #66324

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -212,9 +214,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
void commit() throws IOException {
ensureOpen();
try {
for (CacheIndexWriter writer : writers) {
writer.prepareCommit();
}
for (CacheIndexWriter writer : writers) {
writer.commit();
}
Expand Down Expand Up @@ -457,16 +456,14 @@ void deleteCacheFile(String cacheFileId) throws IOException {
indexWriter.deleteDocuments(term);
}

void prepareCommit() throws IOException {
logger.debug("preparing commit");
final Map<String, String> commitData = new HashMap<>(1);
commitData.put(NODE_VERSION_COMMIT_KEY, Integer.toString(Version.CURRENT.id));
indexWriter.setLiveCommitData(commitData.entrySet());
indexWriter.prepareCommit();
}
private static final Set<Map.Entry<String, String>> LUCENE_COMMIT_DATA = Collections.singletonMap(
NODE_VERSION_COMMIT_KEY,
Integer.toString(Version.CURRENT.id)
).entrySet();

void commit() throws IOException {
logger.debug("committing");
indexWriter.setLiveCommitData(LUCENE_COMMIT_DATA);
indexWriter.commit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,8 @@ public void testCacheIndexWriter() throws Exception {

boolean commit = false;
if (frequently()) {
writer.prepareCommit();
if (frequently()) {
writer.commit();
commit = true;
}
writer.commit();
commit = true;
}

if (commit) {
Expand Down