New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 3 users

Issue metadata

Status: Released
Owner:
Last visit > 30 days ago
Closed: May 10
Cc:
Components:



Sign in to add a comment

Unable to reindex changes on NoteDb

Project Member Reported by luca.mil...@gmail.com, May 4

Issue description

*****************************************************************
*****                                                       *****
***** !!!! THIS BUG TRACKER IS FOR GERRIT CODE REVIEW !!!!  *****
*****                                                       *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, CYANOGENMOD,  *****
***** INTERNAL ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.*****
*****                                                       *****
*****   THOSE ISSUES BELONG IN DIFFERENT ISSUE TRACKERS     *****
*****                                                       *****
*****************************************************************

Affected Version: 2.5.1

What steps will reproduce the problem?
1. Install two Gerrit nodes with the high-availability plugin and NoteDb enabled
2. Create a change on the primary node

What is the expected output?
Change to be automatically reindexed on the secondary node

What do you see instead?
The forward of the reindex event fails with 500

Please provide any additional information below.

See the relevant exception:
[2018-05-04 23:38:13,248] [HTTP-84] ERROR com.google.gerrit.pgm.http.jetty.HiddenErrorHandler : Error in POST /plugins/high-availability/index/change/391876
java.lang.UnsupportedOperationException: This table has been migrated to NoteDb
        at com.google.gerrit.reviewdb.server.DisallowReadFromChangesReviewDbWrapper$Changes.get(DisallowReadFromChangesReviewDbWrapper.java:98)
        at com.ericsson.gerrit.plugins.highavailability.forwarder.ForwardedIndexChangeHandler.doIndex(ForwardedIndexChangeHandler.java:49)
        at com.ericsson.gerrit.plugins.highavailability.forwarder.ForwardedIndexChangeHandler.doIndex(ForwardedIndexChangeHandler.java:34)
        at com.ericsson.gerrit.plugins.highavailability.forwarder.ForwardedIndexingHandler.index(ForwardedIndexingHandler.java:68)


And the section of the code:
  @Override
  protected void doIndex(Change.Id id) throws IOException, OrmException {
    Change change = null;
    try (ReviewDb db = schemaFactory.open()) {
      change = db.changes().get(id);
      if (change != null) {
        indexer.index(db, change);
        logger.debug("Change {} successfully indexed", id);
      }
    } catch (Exception e) {
      if (!isCausedByNoSuchChangeException(e)) {
        throw e;
      }
      logger.debug("Change {} was deleted, aborting forwarded indexing the change.", id.get());
    }
    if (change == null) {
      indexer.delete(id);
      logger.debug("Change {} not found, deleted from index", id);
    }
  }

The code clearly works ONLY with ReviewDb. When used with Gerrit 2.15.1 migrated to NoteDb, the plugin is not able to reindex any change.

 
Project Member

Comment 1 by luca.mil...@gmail.com, May 5

I did a bit more investigation and overall approach needs to change because with NoteDb the change number needs to refer to a project: there isn't anymore a global changes table but each project has its own changes with reviews and change notes.

We need to inject the ChangeNotes and pass the project name on the REST-API that is responsible for reindexing the changes.
Project Member

Comment 2 by luca.mil...@gmail.com, May 5

Status: Started (was: New)
Project Member

Comment 3 by luca.mil...@gmail.com, May 5

Status: ChangeUnderReview (was: Started)

Comment 5 Deleted

Project Member

Comment 6 by luca.mil...@gmail.com, May 10

The cause of the problem isn't the fix but rather different serverId values between the two nodes in HA.

master node has:
[gerrit]
   serverId = 43e200a9-3564-45dd-b00a-0162ac0c42f0

failover node has:
[gerrit]
   serverId = b932246e-f7b1-4bf1-bd74-4fe9b2da7618

If you align the failover node serverId with the same value of the master node, you will notice that the problem will disappear.

Please note that in Gerrit 2.14.x and 2.15.x / ReviewDb, the serverId wasn't relevant. It started to be used and enforced after the migration to NoteDb.
Project Member

Comment 7 by huga...@gmail.com, May 10

Thanks again and sorry for the noise, I am not familiar with all the details of running Gerrit with notedb
Project Member

Comment 8 by huga...@gmail.com, May 10

Status: Released (was: ChangeUnderReview)
Project Member

Comment 9 by huga...@gmail.com, May 10

Thank you for the fix and helping others having a smoother update to 2.15 using notedb

Sign in to add a comment