ChangeIndexer: Disable auto-rebuilding changes in all cases
In I64000a57 we tried to do this, but only fixed one of the cases where a ChangeData was created. Fix the remaining cases. Also correct the NotesMigration check to just check that reads are disabled. (The only difference between the enabled/disabled paths is the value of autoRebuild passed to the ChangeNotes constructor, so it doesn't matter which one we use if both reads and writes are disabled.) Change-Id: Ic55a2ce42782714700bfd156d98ebff24d2063cc
This commit is contained in:
@@ -203,19 +203,7 @@ public class ChangeIndexer {
|
||||
*/
|
||||
public void index(ReviewDb db, Change change)
|
||||
throws IOException, OrmException {
|
||||
ChangeData cd;
|
||||
if (notesMigration.commitChangeWrites()) {
|
||||
// Auto-rebuilding when NoteDb reads are disabled just increases
|
||||
// contention on the meta ref from a background indexing thread with
|
||||
// little benefit. The next actual write to the entity may still incur a
|
||||
// less-contentious rebuild.
|
||||
ChangeNotes notes =
|
||||
changeNotesFactory.createWithAutoRebuildingDisabled(change, null);
|
||||
cd = changeDataFactory.create(db, notes);
|
||||
} else {
|
||||
cd = changeDataFactory.create(db, change);
|
||||
}
|
||||
index(cd);
|
||||
index(newChangeData(db, change));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,8 +214,8 @@ public class ChangeIndexer {
|
||||
* @param changeId ID of the change to index.
|
||||
*/
|
||||
public void index(ReviewDb db, Project.NameKey project, Change.Id changeId)
|
||||
throws IOException {
|
||||
index(changeDataFactory.create(db, project, changeId));
|
||||
throws IOException, OrmException {
|
||||
index(newChangeData(db, project, changeId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,8 +288,8 @@ public class ChangeIndexer {
|
||||
};
|
||||
RequestContext oldCtx = context.setContext(newCtx);
|
||||
try {
|
||||
ChangeData cd = changeDataFactory
|
||||
.create(newCtx.getReviewDbProvider().get(), project, id);
|
||||
ChangeData cd = newChangeData(
|
||||
newCtx.getReviewDbProvider().get(), project, id);
|
||||
index(cd);
|
||||
return null;
|
||||
} finally {
|
||||
@@ -342,4 +330,29 @@ public class ChangeIndexer {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid auto-rebuilding when reindexing if reading is disabled. This just
|
||||
// increases contention on the meta ref from a background indexing thread
|
||||
// with little benefit. The next actual write to the entity may still incur a
|
||||
// less-contentious rebuild.
|
||||
private ChangeData newChangeData(ReviewDb db, Change change)
|
||||
throws OrmException {
|
||||
if (!notesMigration.readChanges()) {
|
||||
ChangeNotes notes = changeNotesFactory.createWithAutoRebuildingDisabled(
|
||||
change, null);
|
||||
return changeDataFactory.create(db, notes);
|
||||
}
|
||||
return changeDataFactory.create(db, change);
|
||||
}
|
||||
|
||||
private ChangeData newChangeData(ReviewDb db, Project.NameKey project,
|
||||
Change.Id changeId) throws OrmException {
|
||||
if (!notesMigration.readChanges()) {
|
||||
ChangeNotes notes = changeNotesFactory.createWithAutoRebuildingDisabled(
|
||||
db, project, changeId);
|
||||
return changeDataFactory.create(db, notes);
|
||||
}
|
||||
return changeDataFactory.create(db, project, changeId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user