Skip to content
Closed
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
8 changes: 8 additions & 0 deletions changelog/unreleased/SOLR-7003.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
title: Remove unused waitFlush boolean from SolrClients
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should clarify it's association to commit

type: removed # added, changed, fixed, deprecated, removed, dependency_update, security, other
authors:
- name: Eric Pugh
links:
- name: SOLR-7003
url: https://issues.apache.org/jira/browse/SOLR-7003
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private static UpdateResponse softCommit(
HttpJettySolrClient solrClient, String baseUrl, String coreName)
throws SolrServerException, IOException {
UpdateRequest ureq = new UpdateRequest();
ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, true, true);
ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The soft commit parameter is being lost in this refactoring. The method is named softCommit and line 226 has a comment 'Calling soft commit to make sub shard updates visible'. The old code was setAction(AbstractUpdateRequest.ACTION.COMMIT, false, true, true) where softCommit=true. The new 3-parameter version defaults softCommit to false. Change to ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true, true) to maintain the soft commit behavior.

Suggested change
ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true, true);

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is true...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err, you are right, I still have some changes to AbstractUpdateRequest to do.

return ureq.processWithBaseUrl(solrClient, baseUrl, coreName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ protected Map<Object, Throwable> indexSampleDocs(
// load sample docs from blob store
CloudSolrClient cloudSolrClient = cloudClient();
cloudSolrClient.deleteByQuery(collectionName, "*:*", 1);
cloudSolrClient.optimize(collectionName, true, true, 1);
cloudSolrClient.optimize(collectionName, true, 1);

final int commitWithin = 100;
final int numDocs = docs.size();
Expand Down Expand Up @@ -1060,7 +1060,7 @@ protected Map<Object, Throwable> indexSampleDocs(
}
}

cloudSolrClient.commit(collectionName, true, true, true);
cloudSolrClient.commit(collectionName, true, true);

if (!errorsDuringIndexing.isEmpty()) {
return errorsDuringIndexing;
Expand All @@ -1084,7 +1084,7 @@ protected long waitToSeeSampleDocs(String collectionName, long numAdded)
// wait up to 5 seconds for this to occur
final long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(5);
do {
cloudSolrClient.commit(collectionName, true, true, true);
cloudSolrClient.commit(collectionName, true, true);
queryResponse = cloudSolrClient.query(collectionName, query);
numFound = queryResponse.getResults().getNumFound();
if (numFound >= numAdded) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void addCommit(UpdateRequest ureq, CommitUpdateCommand cmd) {
if (cmd == null) return;
ureq.setAction(
cmd.optimize ? AbstractUpdateRequest.ACTION.OPTIMIZE : AbstractUpdateRequest.ACTION.COMMIT,
false,
true, // waitFlush - ignored
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment 'waitFlush - ignored' is misleading since this parameter is no longer named waitFlush in the underlying AbstractUpdateRequest.setAction() method - it's still a required parameter at the AbstractUpdateRequest level. A more accurate comment would be 'waitFlush (not used by server but required by API)' or similar to clarify the parameter's status.

Suggested change
true, // waitFlush - ignored
true, // waitFlush (not used by server but required by API)

Copilot uses AI. Check for mistakes.
cmd.waitSearcher,
cmd.maxOptimizeSegments,
cmd.softCommit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void test() throws Exception {

// soft-commit so searchers are open on un-committed but flushed segment files
AbstractUpdateRequest request =
new UpdateRequest().setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true, true);
new UpdateRequest().setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The soft commit parameter is being lost in this refactoring. The old code called setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true, true) where the fourth parameter was softCommit=true. The new 3-parameter version calls the overload that defaults softCommit to false (see AbstractUpdateRequest line 40 which calls line 50). The comment on line 92-93 explicitly states this should be a soft-commit. Change to new UpdateRequest().setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true, true) to preserve the soft commit behavior.

Suggested change
new UpdateRequest().setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
new UpdateRequest().setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true, true);

Copilot uses AI. Check for mistakes.
cloudClient.request(request);

Replica notLeader = ensureAllReplicasAreActive(DEFAULT_COLLECTION, "shard1", 1, 2, 30).get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void run() {

if (rand.nextInt(100) < softCommitPercent) {
log.info("softCommit start");
clients.get(chosenClientIndex).commit(true, true, true);
clients.get(chosenClientIndex).commit(true, true);
log.info("softCommit end");
} else {
log.info("hardCommit start");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public void testIndexOptimization() throws Exception {
}

// Optimize the index.
leaderClient.optimize(true, true, 1);
leaderClient.optimize(true, 1);

// After invoking optimize command, verify that the index directory contains multiple commits
// (including the one we snapshotted earlier).
Expand Down Expand Up @@ -278,7 +278,7 @@ public void testIndexOptimization() throws Exception {
}

// Optimize the index.
leaderClient.optimize(true, true, 1);
leaderClient.optimize(true, 1);

// Verify that the index directory contains only 1 index commit (which is not the same as the
// snapshotted commit).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private long indexDocs(SolrClient client, int totalDocs, int start) throws Excep
for (int i = 0; i < totalDocs; i++)
ReplicationTestHelper.index(
client, "id", i + start, "name", TestUtil.randomSimpleString(random(), 1000, 5000));
client.commit(true, true);
client.commit(true, false); // hard commit (softCommit=false) needed for replication
QueryResponse response =
client.query(
new SolrQuery()
Expand Down
2 changes: 1 addition & 1 deletion solr/core/src/test/org/apache/solr/search/TestSolrJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void doCommitPerf() throws Exception {
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", Integer.toString(i % 13));
client.add(doc);
client.commit(true, true, true);
client.commit(true, true);
}

System.out.println("TIME: " + timer.getTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,7 @@ private String findZkHost(
private void sendCommit() throws IOException {

try {
clientCache
.getCloudSolrClient(zkHost)
.commit(collection, waitFlush, waitSearcher, softCommit);
clientCache.getCloudSolrClient(zkHost).commit(collection, waitSearcher, softCommit);
} catch (SolrServerException | IOException e) {
log.warn(
String.format(
Expand Down
72 changes: 37 additions & 35 deletions solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public UpdateResponse addBeans(final Iterator<?> beanIterator)
/**
* Performs an explicit commit, causing pending documents to be committed for indexing
*
* <p>waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
* <p>waitSearcher=true to be inline with the defaults for plain HTTP access
*
* <p>Be very careful when triggering commits from the client side. Commits are heavy operations
* and WILL impact Solr performance when executed too often or too close together. Instead,
Expand All @@ -421,13 +421,15 @@ public UpdateResponse addBeans(final Iterator<?> beanIterator)
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse commit(String collection) throws SolrServerException, IOException {
return commit(collection, true, true);
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.COMMIT, true, true)
.process(this, collection);
}

/**
* Performs an explicit commit, causing pending documents to be committed for indexing
*
* <p>waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
* <p>waitSearcher=true to be inline with the defaults for plain HTTP access
*
* <p>Be very careful when triggering commits from the client side. Commits are heavy operations
* and WILL impact Solr performance when executed too often or too close together. Instead,
Expand All @@ -440,7 +442,9 @@ public UpdateResponse commit(String collection) throws SolrServerException, IOEx
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse commit() throws SolrServerException, IOException {
return commit(null, true, true);
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.COMMIT, true, true)
.process(this, null);
}

/**
Expand All @@ -452,18 +456,17 @@ public UpdateResponse commit() throws SolrServerException, IOException {
* 'autoCommit' settings.
*
* @param collection the Solr collection to send the commit to
* @param waitFlush block until index changes are flushed to disk
* @param waitSearcher block until a new searcher is opened and registered as the main query
* searcher, making the changes visible
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
* from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse commit(String collection, boolean waitFlush, boolean waitSearcher)
public UpdateResponse commit(String collection, boolean waitSearcher)
throws SolrServerException, IOException {
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.COMMIT, waitFlush, waitSearcher)
.setAction(UpdateRequest.ACTION.COMMIT, true, waitSearcher)
.process(this, collection);
}

Expand All @@ -475,17 +478,15 @@ public UpdateResponse commit(String collection, boolean waitFlush, boolean waitS
* consider using 'commitWithin' when adding documents or rely on your core's/collection's
* 'autoCommit' settings.
*
* @param waitFlush block until index changes are flushed to disk
* @param waitSearcher block until a new searcher is opened and registered as the main query
* searcher, making the changes visible
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
* from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse commit(boolean waitFlush, boolean waitSearcher)
throws SolrServerException, IOException {
return commit(null, waitFlush, waitSearcher);
public UpdateResponse commit(boolean waitSearcher) throws SolrServerException, IOException {
return commit(null, waitSearcher);
}

/**
Expand All @@ -497,7 +498,6 @@ public UpdateResponse commit(boolean waitFlush, boolean waitSearcher)
* 'autoCommit' settings.
*
* @param collection the Solr collection to send the commit to
* @param waitFlush block until index changes are flushed to disk
* @param waitSearcher block until a new searcher is opened and registered as the main query
* searcher, making the changes visible
* @param softCommit makes index changes visible while neither fsync-ing index files nor writing a
Expand All @@ -507,11 +507,10 @@ public UpdateResponse commit(boolean waitFlush, boolean waitSearcher)
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse commit(
String collection, boolean waitFlush, boolean waitSearcher, boolean softCommit)
public UpdateResponse commit(String collection, boolean waitSearcher, boolean softCommit)
throws SolrServerException, IOException {
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.COMMIT, waitFlush, waitSearcher, softCommit)
.setAction(UpdateRequest.ACTION.COMMIT, true, waitSearcher, softCommit)
.process(this, collection);
}

Expand All @@ -523,7 +522,6 @@ public UpdateResponse commit(
* consider using 'commitWithin' when adding documents or rely on your core's/collection's
* 'autoCommit' settings.
*
* @param waitFlush block until index changes are flushed to disk
* @param waitSearcher block until a new searcher is opened and registered as the main query
* searcher, making the changes visible
* @param softCommit makes index changes visible while neither fsync-ing index files nor writing a
Expand All @@ -533,9 +531,11 @@ public UpdateResponse commit(
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse commit(boolean waitFlush, boolean waitSearcher, boolean softCommit)
public UpdateResponse commit(boolean waitSearcher, boolean softCommit)
throws SolrServerException, IOException {
return commit(null, waitFlush, waitSearcher, softCommit);
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.COMMIT, true, waitSearcher, softCommit)
.process(this, null);
}

/**
Expand All @@ -552,13 +552,15 @@ public UpdateResponse commit(boolean waitFlush, boolean waitSearcher, boolean so
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse optimize(String collection) throws SolrServerException, IOException {
return optimize(collection, true, true, 1);
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.OPTIMIZE, true, true, 1)
.process(this, collection);
}

/**
* Performs an explicit optimize, causing a merge of all segments to one.
*
* <p>waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
* <p>waitSearcher=true to be inline with the defaults for plain HTTP access
*
* <p>Note: In most cases it is not required to do explicit optimize
*
Expand All @@ -568,7 +570,9 @@ public UpdateResponse optimize(String collection) throws SolrServerException, IO
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse optimize() throws SolrServerException, IOException {
return optimize(null, true, true, 1);
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.OPTIMIZE, true, true, 1)
.process(this, null);
}

/**
Expand All @@ -577,35 +581,34 @@ public UpdateResponse optimize() throws SolrServerException, IOException {
* <p>Note: In most cases it is not required to do explicit optimize
*
* @param collection the Solr collection to send the optimize command to
* @param waitFlush block until index changes are flushed to disk
* @param waitSearcher block until a new searcher is opened and registered as the main query
* searcher, making the changes visible
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
* from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse optimize(String collection, boolean waitFlush, boolean waitSearcher)
public UpdateResponse optimize(String collection, boolean waitSearcher)
throws SolrServerException, IOException {
return optimize(collection, waitFlush, waitSearcher, 1);
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.OPTIMIZE, true, waitSearcher, 1)
.process(this, collection);
}

/**
* Performs an explicit optimize, causing a merge of all segments to one.
*
* <p>Note: In most cases it is not required to do explicit optimize
*
* @param waitFlush block until index changes are flushed to disk
* @param waitSearcher block until a new searcher is opened and registered as the main query
* searcher, making the changes visible
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
* from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher)
throws SolrServerException, IOException {
return optimize(null, waitFlush, waitSearcher);
public UpdateResponse optimize(boolean waitSearcher) throws SolrServerException, IOException {
return optimize(null, waitSearcher);
}

/**
Expand All @@ -614,7 +617,6 @@ public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher)
* <p>Note: In most cases it is not required to do explicit optimize
*
* @param collection the Solr collection to send the optimize command to
* @param waitFlush block until index changes are flushed to disk
* @param waitSearcher block until a new searcher is opened and registered as the main query
* searcher, making the changes visible
* @param maxSegments optimizes down to at most this number of segments
Expand All @@ -623,11 +625,10 @@ public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher)
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse optimize(
String collection, boolean waitFlush, boolean waitSearcher, int maxSegments)
public UpdateResponse optimize(String collection, boolean waitSearcher, int maxSegments)
throws SolrServerException, IOException {
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.OPTIMIZE, waitFlush, waitSearcher, maxSegments)
.setAction(UpdateRequest.ACTION.OPTIMIZE, true, waitSearcher, maxSegments)
.process(this, collection);
}

Expand All @@ -636,7 +637,6 @@ public UpdateResponse optimize(
*
* <p>Note: In most cases it is not required to do explicit optimize
*
* @param waitFlush block until index changes are flushed to disk
* @param waitSearcher block until a new searcher is opened and registered as the main query
* searcher, making the changes visible
* @param maxSegments optimizes down to at most this number of segments
Expand All @@ -645,9 +645,11 @@ public UpdateResponse optimize(
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher, int maxSegments)
public UpdateResponse optimize(boolean waitSearcher, int maxSegments)
throws SolrServerException, IOException {
return optimize(null, waitFlush, waitSearcher, maxSegments);
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.OPTIMIZE, true, waitSearcher, maxSegments)
.process(this, null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public void testExampleConfig() throws Exception {
// System.out.println( "COMMIT:"+upres.getResponse() );
assertEquals(0, upres.getStatus());

upres = client.optimize(true, true);
upres = client.optimize(true);
// System.out.println( "OPTIMIZE:"+upres.getResponse() );
assertEquals(0, upres.getStatus());

Expand Down Expand Up @@ -371,7 +371,7 @@ public void testExampleConfig() throws Exception {
// System.out.println( "COMMIT:"+upres.getResponse() );
assertEquals(0, upres.getStatus());

upres = client.optimize(true, true);
upres = client.optimize(true);
// System.out.println( "OPTIMIZE:"+upres.getResponse() );
assertEquals(0, upres.getStatus());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void run() {
log.debug("StoppableCommitThread started");
while (!stop) {
try {
cloudClient.commit(false, false, softCommits);
cloudClient.commit(false, softCommits);
numCommits.incrementAndGet();
} catch (Exception e) {
numFails.incrementAndGet();
Expand Down
Loading