Skip to content
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

Merged
merged 4 commits into from
Jul 3, 2024

Conversation

debdutdeb
Copy link
Member

@debdutdeb debdutdeb commented Jun 3, 2024

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 tracked

We 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

Copy link
Contributor

dionisio-bot bot commented Jun 3, 2024

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 6.11.0, but it targets 6.10.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented Jun 3, 2024

🦋 Changeset detected

Latest commit: 67faa99

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 32 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/api-client Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/models Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/instance-status Patch

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

Copy link

codecov bot commented Jun 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.71%. Comparing base (eb5f93c) to head (67faa99).

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
e2e 56.46% <ø> (-0.04%) ⬇️
unit 71.94% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@debdutdeb debdutdeb marked this pull request as ready for review June 24, 2024 17:54
Copy link
Member

@MarcosSpessatto MarcosSpessatto left a 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.

@debdutdeb
Copy link
Member Author

@MarcosSpessatto I believe expected, as with OVERWRITE we updated the setting record. I didn't change any code related to that.

@casalsgh casalsgh added stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge labels Jul 1, 2024
@casalsgh casalsgh added this to the 6.11 milestone Jul 3, 2024
@casalsgh casalsgh merged commit 06707d8 into develop Jul 3, 2024
50 of 71 checks passed
@casalsgh casalsgh deleted the fix-stale-setting-cache branch July 3, 2024 15:02
debdutdeb added a commit that referenced this pull request Jul 17, 2024
@debdutdeb debdutdeb mentioned this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants