Expose IndexCollection in plugin guice injector
Secondary index underwent quite some evolution, by adding new fields or turning search predicates that (uncorrectly) used database to produce matches to use secondary index. When new index version is added, the previous index version must still be supported because of online reindexing feature. On very big site, reindexing may take hours, clearly such a long offline time is non acceptable, that why online reindexing feature was invented. To make online reindexing work, schema version must be fetched to route the current search predicate to use old (legacy) or new field. For that IndexCollection is accessed and the current schema version is read. Unfortunately, IndexCollection implements LifecycleListener and these classes are not copied in guice plugin injector when the plugin is loaded. This makes secondary index machinery not usable from within a plugin listener. For the reasons explained above some search predicates would try to retrieve the secondary index version but because singleton IndexCollection instance wasn't made available in plugin's guice injector, the correct instance is not found and guice injector creates new virgin IndexCollection instance where change index (and the schema version) is not set. As the consequence we are getting a NPE when secondary index is tried to be used from within plugin listener. To rectify, expose IndexCollection to plugin guice injector. Bug: Issue 3768 Change-Id: I2f9c40aa43aa7b1b954d8fa318df54e45dffcd95
This commit is contained in:
committed by
David Ostrovsky
parent
a533b1519c
commit
a5f2037a42
@@ -553,7 +553,9 @@ public class PluginGuiceEnvironment {
|
||||
return false;
|
||||
}
|
||||
Class<?> type = key.getTypeLiteral().getRawType();
|
||||
if (LifecycleListener.class.isAssignableFrom(type)) {
|
||||
if (LifecycleListener.class.isAssignableFrom(type)
|
||||
// This is needed for secondary index to work from plugin listeners
|
||||
&& !is("com.google.gerrit.server.index.IndexCollection", type)) {
|
||||
return false;
|
||||
}
|
||||
if (StartPluginListener.class.isAssignableFrom(type)) {
|
||||
|
||||
Reference in New Issue
Block a user