Add config option to reindex all groups on slave startup

If enabled the slave startup is blocked until all stale groups were
reindexed. Enabling this allows to prevent that slaves that were offline
for a longer period of time run with outdated group information until
the first scheduled indexing is done.

E.g. if a slave was offline for 3 weeks and groups are not reindexed on
startup the slave sees group information that is 3 weeks old until the
first scheduled indexing is done. This may be a security issue.

Change-Id: I57ac7ef5c823ec18beef8c19ef159e400b7ada71
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-02-16 17:18:31 +01:00
parent 0f0de8624d
commit a32d4436fc
4 changed files with 45 additions and 5 deletions

View File

@@ -343,9 +343,6 @@ public abstract class AbstractDaemonTest {
server.getTestInjector().injectMembers(resetter);
}
initSsh();
// The server restart threw away all indices. Only reindex all groups as we only have the group
// index in slave mode.
reindexAllGroups();
}
private void reindexAllGroups() throws OrmException, IOException, ConfigInvalidException {

View File

@@ -82,6 +82,11 @@ public class PeriodicGroupIndexer implements Runnable {
@Override
public void start() {
boolean runOnStartup = cfg.getBoolean("index", "scheduledIndexer", "runOnStartup", true);
if (runOnStartup) {
runner.run();
}
boolean isEnabled = cfg.getBoolean("index", "scheduledIndexer", "enabled", true);
if (!isEnabled) {
log.warn("index.scheduledIndexer is disabled");