Merge "ChangeIndexer: Disable auto-rebuilding changes in all cases"
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
||||
return changes.get(0).notes();
|
||||
}
|
||||
|
||||
public ChangeNotes create(ReviewDb db, Project.NameKey project,
|
||||
private Change loadChangeFromDb(ReviewDb db, Project.NameKey project,
|
||||
Change.Id changeId) throws OrmException {
|
||||
Change change = ReviewDbUtil.unwrapDb(db).changes().get(changeId);
|
||||
checkNotNull(change,
|
||||
@@ -160,7 +160,19 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
||||
project, changeId, change.getProject());
|
||||
// TODO: Throw NoSuchChangeException when the change is not found in the
|
||||
// database
|
||||
return new ChangeNotes(args, change).load();
|
||||
return change;
|
||||
}
|
||||
|
||||
public ChangeNotes create(ReviewDb db, Project.NameKey project,
|
||||
Change.Id changeId) throws OrmException {
|
||||
return new ChangeNotes(args, loadChangeFromDb(db, project, changeId))
|
||||
.load();
|
||||
}
|
||||
|
||||
public ChangeNotes createWithAutoRebuildingDisabled(ReviewDb db,
|
||||
Project.NameKey project, Change.Id changeId) throws OrmException {
|
||||
return new ChangeNotes(
|
||||
args, loadChangeFromDb(db, project, changeId), false, null).load();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user