martin-g commented on a change in pull request #684: LUCENE-8809: Ensure release segment states URL: https://github.com/apache/lucene-solr/pull/684#discussion_r286918182
########## File path: lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java ########## @@ -3730,4 +3733,50 @@ public void testFlushWhileStartingNewThreads() throws IOException, InterruptedEx dir.close(); } + public void testRefreshAndRollbackConcurrently() throws Exception { + Directory dir = newDirectory(); + IndexWriter w = new IndexWriter(dir, newIndexWriterConfig()); + AtomicBoolean stopped = new AtomicBoolean(); + Semaphore indexedDocs = new Semaphore(0); + Thread indexer = new Thread(() -> { + while (stopped.get() == false) { + try { + String id = Integer.toString(random().nextInt(100)); + Document doc = new Document(); + doc.add(new StringField("id", id, Field.Store.YES)); + w.updateDocument(new Term("id", id), doc); + indexedDocs.release(1); + } catch (IOException e) { + throw new AssertionError(e); + } catch (AlreadyClosedException ignored) { + return; + } + } + }); + + SearcherManager sm = new SearcherManager(w, new SearcherFactory()); + Thread refresher = new Thread(() -> { + while (stopped.get() == false) { + try { + sm.maybeRefreshBlocking(); + } catch (IOException e) { + throw new AssertionError(e); + } catch (AlreadyClosedException ignored) { + return; + } + } + }); + + try { + indexer.start(); + refresher.start(); + indexedDocs.acquire(1 + random().nextInt(100)); + w.rollback(); + } finally { + stopped.get(); Review comment: What is this doing here ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org