You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2018/03/19 21:10:25 UTC

[1/2] lucene-solr:master: LUCENE-8212: Make sure terms hash is always closed

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 18e040290 -> a00f5416a
  refs/heads/master a83241184 -> 65559cb94


LUCENE-8212: Make sure terms hash is always closed

if stored fields writer barfs we still need to close terms hash to
close pending files. This is crucial for some tests like TestIndexWriterOnVMError
that randomly failed due to this.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/65559cb9
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/65559cb9
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/65559cb9

Branch: refs/heads/master
Commit: 65559cb94d2cbbc9081f6f5d6d8f6bac055b11e6
Parents: a832411
Author: Simon Willnauer <si...@apache.org>
Authored: Mon Mar 19 21:56:48 2018 +0100
Committer: Simon Willnauer <si...@apache.org>
Committed: Mon Mar 19 22:08:25 2018 +0100

----------------------------------------------------------------------
 .../org/apache/lucene/index/DefaultIndexingChain.java    | 11 ++++++-----
 .../src/java/org/apache/lucene/index/DocConsumer.java    |  2 +-
 .../java/org/apache/lucene/index/DocumentsWriter.java    |  4 ++--
 .../apache/lucene/index/DocumentsWriterPerThread.java    |  5 ++---
 4 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/65559cb9/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
index c929797..4541f4a 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
@@ -17,6 +17,7 @@
 package org.apache.lucene.index;
 
 
+import java.io.Closeable;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -322,11 +323,11 @@ final class DefaultIndexingChain extends DocConsumer {
   }
 
   @Override
-  public void abort() {
-    storedFieldsConsumer.abort();
-    try {
-      // E.g. close any open files in the term vectors writer:
-      termsHash.abort();
+  @SuppressWarnings("try")
+  public void abort() throws IOException{
+    // finalizer will e.g. close any open files in the term vectors writer:
+    try (Closeable finalizer = termsHash::abort){
+      storedFieldsConsumer.abort();
     } finally {
       Arrays.fill(fieldHash, null);
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/65559cb9/lucene/core/src/java/org/apache/lucene/index/DocConsumer.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocConsumer.java b/lucene/core/src/java/org/apache/lucene/index/DocConsumer.java
index 8ff5704..a64f13c 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocConsumer.java
@@ -22,5 +22,5 @@ import java.io.IOException;
 abstract class DocConsumer {
   abstract void processDocument() throws IOException;
   abstract Sorter.DocMap flush(final SegmentWriteState state) throws IOException;
-  abstract void abort();
+  abstract void abort() throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/65559cb9/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
index 616915b..f848b2a 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
@@ -221,7 +221,7 @@ final class DocumentsWriter implements Closeable, Accountable {
    *  updating the index files) and must discard all
    *  currently buffered docs.  This resets our state,
    *  discarding any docs added since last flush. */
-  synchronized void abort(IndexWriter writer) {
+  synchronized void abort(IndexWriter writer) throws IOException {
     assert !Thread.holdsLock(writer) : "IndexWriter lock should never be hold when aborting";
     boolean success = false;
     try {
@@ -324,7 +324,7 @@ final class DocumentsWriter implements Closeable, Accountable {
   }
   
   /** Returns how many documents were aborted. */
-  private int abortThreadState(final ThreadState perThread) {
+  private int abortThreadState(final ThreadState perThread) throws IOException {
     assert perThread.isHeldByCurrentThread();
     if (perThread.isInitialized()) { 
       try {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/65559cb9/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
index d5ebc60..32a783a 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
@@ -126,8 +126,7 @@ class DocumentsWriterPerThread {
    *  updating the index files) and must discard all
    *  currently buffered docs.  This resets our state,
    *  discarding any docs added since last flush. */
-  void abort() {
-    //System.out.println(Thread.currentThread().getName() + ": now abort seg=" + segmentInfo.name);
+  void abort() throws IOException{
     aborted = true;
     pendingNumDocs.addAndGet(-numDocsInRAM);
     try {
@@ -513,7 +512,7 @@ class DocumentsWriterPerThread {
     }
   }
 
-  private void maybeAbort(String location) {
+  private void maybeAbort(String location) throws IOException {
     if (hasHitAbortingException() && aborted == false) {
       // if we are already aborted don't do anything here
       try {


[2/2] lucene-solr:branch_7x: LUCENE-8212: Make sure terms hash is always closed

Posted by si...@apache.org.
LUCENE-8212: Make sure terms hash is always closed

if stored fields writer barfs we still need to close terms hash to
close pending files. This is crucial for some tests like TestIndexWriterOnVMError
that randomly failed due to this.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a00f5416
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a00f5416
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a00f5416

Branch: refs/heads/branch_7x
Commit: a00f5416afeb742213484400a4bf35f23ec47ce6
Parents: 18e0402
Author: Simon Willnauer <si...@apache.org>
Authored: Mon Mar 19 21:56:48 2018 +0100
Committer: Simon Willnauer <si...@apache.org>
Committed: Mon Mar 19 22:09:36 2018 +0100

----------------------------------------------------------------------
 .../org/apache/lucene/index/DefaultIndexingChain.java    | 11 ++++++-----
 .../src/java/org/apache/lucene/index/DocConsumer.java    |  2 +-
 .../java/org/apache/lucene/index/DocumentsWriter.java    |  4 ++--
 .../apache/lucene/index/DocumentsWriterPerThread.java    |  5 ++---
 4 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a00f5416/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
index 010d1a6..1fcd49d 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
@@ -17,6 +17,7 @@
 package org.apache.lucene.index;
 
 
+import java.io.Closeable;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -311,11 +312,11 @@ final class DefaultIndexingChain extends DocConsumer {
   }
 
   @Override
-  public void abort() {
-    storedFieldsConsumer.abort();
-    try {
-      // E.g. close any open files in the term vectors writer:
-      termsHash.abort();
+  @SuppressWarnings("try")
+  public void abort() throws IOException{
+    // finalizer will e.g. close any open files in the term vectors writer:
+    try (Closeable finalizer = termsHash::abort){
+      storedFieldsConsumer.abort();
     } finally {
       Arrays.fill(fieldHash, null);
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a00f5416/lucene/core/src/java/org/apache/lucene/index/DocConsumer.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocConsumer.java b/lucene/core/src/java/org/apache/lucene/index/DocConsumer.java
index 8ff5704..a64f13c 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocConsumer.java
@@ -22,5 +22,5 @@ import java.io.IOException;
 abstract class DocConsumer {
   abstract void processDocument() throws IOException;
   abstract Sorter.DocMap flush(final SegmentWriteState state) throws IOException;
-  abstract void abort();
+  abstract void abort() throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a00f5416/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
index 616915b..f848b2a 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
@@ -221,7 +221,7 @@ final class DocumentsWriter implements Closeable, Accountable {
    *  updating the index files) and must discard all
    *  currently buffered docs.  This resets our state,
    *  discarding any docs added since last flush. */
-  synchronized void abort(IndexWriter writer) {
+  synchronized void abort(IndexWriter writer) throws IOException {
     assert !Thread.holdsLock(writer) : "IndexWriter lock should never be hold when aborting";
     boolean success = false;
     try {
@@ -324,7 +324,7 @@ final class DocumentsWriter implements Closeable, Accountable {
   }
   
   /** Returns how many documents were aborted. */
-  private int abortThreadState(final ThreadState perThread) {
+  private int abortThreadState(final ThreadState perThread) throws IOException {
     assert perThread.isHeldByCurrentThread();
     if (perThread.isInitialized()) { 
       try {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a00f5416/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
index d5ebc60..32a783a 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
@@ -126,8 +126,7 @@ class DocumentsWriterPerThread {
    *  updating the index files) and must discard all
    *  currently buffered docs.  This resets our state,
    *  discarding any docs added since last flush. */
-  void abort() {
-    //System.out.println(Thread.currentThread().getName() + ": now abort seg=" + segmentInfo.name);
+  void abort() throws IOException{
     aborted = true;
     pendingNumDocs.addAndGet(-numDocsInRAM);
     try {
@@ -513,7 +512,7 @@ class DocumentsWriterPerThread {
     }
   }
 
-  private void maybeAbort(String location) {
+  private void maybeAbort(String location) throws IOException {
     if (hasHitAbortingException() && aborted == false) {
       // if we are already aborted don't do anything here
       try {