Solr
  1. Solr
  2. SOLR-6224

Post soft-commit callbacks are called before soft commit actually happens

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.9
    • Fix Version/s: 5.0, 6.0
    • Component/s: update
    • Labels:
      None

      Description

      DirectUpdateHandler2 has the following code:

      if (!cmd.softCommit) {
                synchronized (solrCoreState.getUpdateLock()) { // sync is currently needed to prevent preCommit
                                      // from being called between preSoft and
                                      // postSoft... see postSoft comments.
                  if (ulog != null) ulog.preCommit(cmd);
                }
                
                // SolrCore.verbose("writer.commit() start writer=",writer);
      
                if (writer.hasUncommittedChanges()) {
                  final Map<String,String> 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();
              } else {
                callPostSoftCommitCallbacks();
              }
      

      As evident in the code above, if cmd.softCommit is true then the post soft commit hooks are called first and the actual soft commit happens in a block of code after it.

      1. SOLR-6224.patch
        4 kB
        Shalin Shekhar Mangar
      2. SOLR-6224.patch
        4 kB
        Shalin Shekhar Mangar

        Activity

        Hide
        Shalin Shekhar Mangar added a comment -

        Test and fix attached.

        Show
        Shalin Shekhar Mangar added a comment - Test and fix attached.
        Hide
        Shalin Shekhar Mangar added a comment -

        Added an assert to make sure postSoftCommit hook was being invoked.

        Show
        Shalin Shekhar Mangar added a comment - Added an assert to make sure postSoftCommit hook was being invoked.
        Hide
        ASF subversion and git services added a comment -

        Commit 1633676 from shalin@apache.org in branch 'dev/trunk'
        [ https://svn.apache.org/r1633676 ]

        SOLR-6224: Post soft-commit callbacks are called before soft commit actually happens

        Show
        ASF subversion and git services added a comment - Commit 1633676 from shalin@apache.org in branch 'dev/trunk' [ https://svn.apache.org/r1633676 ] SOLR-6224 : Post soft-commit callbacks are called before soft commit actually happens
        Hide
        ASF subversion and git services added a comment -

        Commit 1633677 from shalin@apache.org in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1633677 ]

        SOLR-6224: Post soft-commit callbacks are called before soft commit actually happens

        Show
        ASF subversion and git services added a comment - Commit 1633677 from shalin@apache.org in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1633677 ] SOLR-6224 : Post soft-commit callbacks are called before soft commit actually happens
        Hide
        Anshum Gupta added a comment -

        Bulk close after 5.0 release.

        Show
        Anshum Gupta added a comment - Bulk close after 5.0 release.

          People

          • Assignee:
            Shalin Shekhar Mangar
            Reporter:
            Shalin Shekhar Mangar
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development