You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2025/04/28 19:30:25 UTC
(couchdb) branch 5521-handle-closed-index created (now 0662706a7)
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a change to branch 5521-handle-closed-index
in repository https://gitbox.apache.org/repos/asf/couchdb.git
at 0662706a7 reopen an index if Lucene closed it for any reason
This branch includes the following new commits:
new ecf04c24c always remove holder when unloading
new 0662706a7 reopen an index if Lucene closed it for any reason
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(couchdb) 02/02: reopen an index if Lucene closed it for any reason
Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch 5521-handle-closed-index
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 0662706a7fe991b125ea7e193fc30fd996c09f79
Author: Robert Newson <rn...@apache.org>
AuthorDate: Mon Apr 28 18:57:19 2025 +0100
reopen an index if Lucene closed it for any reason
closes #5521
---
.../main/java/org/apache/couchdb/nouveau/core/Index.java | 6 ++++++
.../java/org/apache/couchdb/nouveau/core/IndexManager.java | 14 ++++++++++++--
.../org/apache/couchdb/nouveau/lucene9/Lucene9Index.java | 5 +++++
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/nouveau/src/main/java/org/apache/couchdb/nouveau/core/Index.java b/nouveau/src/main/java/org/apache/couchdb/nouveau/core/Index.java
index 69c9bd48f..35013bf8d 100644
--- a/nouveau/src/main/java/org/apache/couchdb/nouveau/core/Index.java
+++ b/nouveau/src/main/java/org/apache/couchdb/nouveau/core/Index.java
@@ -129,6 +129,12 @@ public abstract class Index implements Closeable {
return deleteOnClose;
}
+ public final boolean isOpen() {
+ return doIsOpen();
+ }
+
+ protected abstract boolean doIsOpen();
+
public synchronized void setDeleteOnClose(final boolean deleteOnClose) {
this.deleteOnClose = deleteOnClose;
}
diff --git a/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java b/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java
index fe65afad2..85230d322 100644
--- a/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java
+++ b/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java
@@ -119,11 +119,21 @@ public final class IndexManager implements Managed {
// CachedData pattern from ReentrantReadWriteLock javadoc
holder.lock.readLock().lock();
- // Load if not already loaded.
- if (holder.state == HolderState.NOT_LOADED) {
+ // Load if not already loaded or remove if Lucene closed the index elsewhere.
+ if (holder.state == HolderState.NOT_LOADED
+ || (holder.state == HolderState.LOADED && !holder.index.isOpen())) {
holder.lock.readLock().unlock();
holder.lock.writeLock().lock();
try {
+ if (holder.state == HolderState.LOADED && !holder.index.isOpen()) {
+ LOGGER.info("removing closed index {}", name);
+ holder.state = HolderState.UNLOADED;
+ holder.index = null;
+ synchronized (cache) {
+ cache.remove(name, holder);
+ }
+ continue retry;
+ }
if (holder.state == HolderState.NOT_LOADED) {
holder.index = load(name);
holder.commitFuture = this.schedulerExecutorService.scheduleWithFixedDelay(
diff --git a/nouveau/src/main/java/org/apache/couchdb/nouveau/lucene9/Lucene9Index.java b/nouveau/src/main/java/org/apache/couchdb/nouveau/lucene9/Lucene9Index.java
index e4e8402e7..dad3040f3 100644
--- a/nouveau/src/main/java/org/apache/couchdb/nouveau/lucene9/Lucene9Index.java
+++ b/nouveau/src/main/java/org/apache/couchdb/nouveau/lucene9/Lucene9Index.java
@@ -190,6 +190,11 @@ public class Lucene9Index extends Index {
});
}
+ @Override
+ public boolean doIsOpen() {
+ return writer.isOpen();
+ }
+
@Override
public SearchResults doSearch(final SearchRequest request) throws IOException {
final Query query = parse(request);
(couchdb) 01/02: always remove holder when unloading
Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch 5521-handle-closed-index
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit ecf04c24c2ce5fb889140166b57e1cde66be2f41
Author: Robert Newson <rn...@apache.org>
AuthorDate: Mon Apr 28 17:33:55 2025 +0100
always remove holder when unloading
---
.../src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java b/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java
index d4a0e8f10..fe65afad2 100644
--- a/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java
+++ b/nouveau/src/main/java/org/apache/couchdb/nouveau/core/IndexManager.java
@@ -188,9 +188,6 @@ public final class IndexManager implements Managed {
}
holder.state = HolderState.UNLOADED;
holder.index = null;
- synchronized (cache) {
- cache.remove(name, holder);
- }
break;
case NOT_LOADED:
case UNLOADED:
@@ -200,6 +197,9 @@ public final class IndexManager implements Managed {
break;
}
} finally {
+ synchronized (cache) {
+ cache.remove(name, holder);
+ }
holder.lock.writeLock().unlock();
}
}