-
Notifications
You must be signed in to change notification settings - Fork 87
TRUNK-6409: Initializer module should not re-run initialization on each node #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6cc66c7
b916fd5
ff6848d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,14 +82,38 @@ public void started() { | |
| log.info("OpenMRS config loading process disabled at initializer startup"); | ||
| } else { | ||
| boolean throwError = PROPS_STARTUP_LOAD_FAIL_ON_ERROR.equalsIgnoreCase(startupLoadingMode); | ||
| log.info("OpenMRS config loading process started..."); | ||
| boolean lockAquired = false; | ||
| String lockName = "initializer"; | ||
|
|
||
| try { | ||
| log.info("Waiting for initializer lock..."); | ||
| getInitializerService().acquireLockOrWait(lockName, 15 * 60 * 1000); // 15 minutes | ||
| lockAquired = true; | ||
|
|
||
| // Check if config changed | ||
| if (!getInitializerService().isConfigChanged()) { | ||
| log.info("No config changes... skipping initializer"); | ||
| return; | ||
| } | ||
|
|
||
| // Run Initializer | ||
| log.info("OpenMRS config loading process started..."); | ||
| getInitializerService().loadUnsafe(true, throwError); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that with your changes if only a single checksum is different, then all files are being loaded again instead of just the one that changed... It's not correct. Only that single file should run. I'll fix that issue. |
||
|
|
||
| // Save new checksums | ||
| getInitializerService().updateChecksums(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not updateChecksums all at once... It's possible that some files get imported and checksums should be updated and some fail... I'll address that as well. |
||
| log.info("OpenMRS config loading process completed."); | ||
| } | ||
| catch (Exception e) { | ||
| log.error("Initializer failed", e); | ||
| throw new ModuleException("An error occurred loading initializer configuration", e); | ||
| } | ||
| finally { | ||
| if (lockAquired) { | ||
| getInitializerService().releaseLock(lockName); | ||
| log.info("Initializer lock released"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't be just skipping. It should be waiting until lock is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, I get it now, thanks for the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean it should wait and then skip. The wait is so that we don't start up another instance before initialization is done.