diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java index 6f185a5f640..e13a41ee610 100644 --- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java +++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java @@ -540,11 +540,17 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState } // SolrCore.verbose("writer.commit() start writer=",writer); - final Map commitData = new HashMap(); - commitData.put(SolrIndexWriter.COMMIT_TIME_MSEC_KEY, - String.valueOf(System.currentTimeMillis())); - writer.setCommitData(commitData); - writer.commit(); + + if (writer.hasUncommittedChanges()) { + final Map commitData = new HashMap(); + commitData.put(SolrIndexWriter.COMMIT_TIME_MSEC_KEY, + String.valueOf(System.currentTimeMillis())); + writer.setCommitData(commitData); + writer.commit(); + } else { + log.info("No uncommitted changes. Skipping IW.commit."); + } + // SolrCore.verbose("writer.commit() end"); numDocsPending.set(0); callPostCommitCallbacks();