-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
fix: update cached setting immediately at the time of updating the db #32541
Conversation
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: 67faa99 The changes in this PR will be included in the next version bump. This PR includes changesets to release 32 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #32541 +/- ##
===========================================
- Coverage 56.73% 56.71% -0.03%
===========================================
Files 2498 2495 -3
Lines 55385 55352 -33
Branches 11455 11448 -7
===========================================
- Hits 31424 31394 -30
- Misses 21256 21259 +3
+ Partials 2705 2699 -6
Flags with carried forward coverage won't be shown. Click here to find out more. |
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.
Tested it locally using the use case you mentioned. I think I found a possible issue. I was able to reproduce following the step-by-step, but after running the steps, I started the server again without the OVERWRITE env var, and the value is not being updated anymore (to the default one). I'm not sure if this is the expected behavior though.
Also, we need to add a changeset to the PR.
@MarcosSpessatto I believe expected, as with OVERWRITE we updated the setting record. I didn't change any code related to that. |
Proposed changes (including videos or screenshots)
Refreshing cache was depending on changestream, as the update in SettingRegistry rounds back through oplog to our watchers, then some listener.
Problem was that in such a case if anything asks for those setting values BEFORE oplog has got back (slow mongo, or slow instance/server) or we have processed the update, they'll get an old value, not the one intended. This becomes a problem when and if an initialization can't be changed on the fly, and restart will be required to use the right value.
The behavior would be noticed when the setting has already been inserted once with one value, before using OVERWRITE_SETTING_.+
IIUC, now, we'd have to add listener callbacks (watch, watchMultiple, etc) BEFORE
settingRegistry.add
, so that the callbacks actually get called, as they are indeed changes to track and behave to, but then even inserts will be trackedWe are discussing if this solution makes sense.
Issue(s)
Steps to test or reproduce
For a clearer visible example, remove Site_Url record from db, unset OVERWRITE_SETTING_Site_Url if you already have one, let the server start and insert the default record.
Now stop the server, set the OVERWRITE_.. start the server and notice the startup ascii banner showing old siteurl (:3000) not the new one.
Further comments
CORE-517