OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.42k stars 2.39k forks source link

Serious Issue, certain settings being synced across dev, uat and prod environments #11930

Closed kgwadu closed 2 years ago

kgwadu commented 2 years ago

We have noticed a very serious issue where certain changes made on one environment are being pushed to 2 other environments.

  1. Changing a content type locally will apply the same change on uat (azure web app) and prod (azure web app). We have the physical content definition file
  2. Changing the recaptcha keys (security > settings > recaptcha) will also change the keys on the other 2 environments
  3. Changing the base url in configuration > settings > general will also change the url on the other 2 environments.

We have not noticed this behaviour on any of our other OC websites, any help would be greatly appreciated, this is causing a lot of problems for us.

sebastienros commented 2 years ago

is it possible that you are using the same redis instance (in case you use redis to sync your nodes) ?

kgwadu commented 2 years ago

We use redis cache to store data from third party apis (custom implementation), we havent done anything with redis and orchardcore. Will check though if orchard core is somehow using our redis cache for anything.

kgwadu commented 2 years ago

@sebastienros I can confirm that Orchard Core is storing a bunch of data in our redis cache. We do not have any of the redis features enabled, how do we prevent Orchard Core from using our redis cache??

sebastienros commented 2 years ago

It can't store in Redis if no redis feature is configured (that's the theory). What kind of data is stored? You could then use this to verify the corresponding feature is really not enabled.

kgwadu commented 2 years ago

@sebastienros First image is what OC is storing in Redis, the second screenshot is the Redis features.

image image

sebastienros commented 2 years ago

Re-reading the issue, isn't it normal if your two environments are using the same database? Isn't it the case? These settings are stored in the db (though I am not sure about the content types).

kgwadu commented 2 years ago

@sebastienros so ultimately the problem is that orchard core is using our redis cache resource even though we havent enabled any features related to redis cache. We have been unsuccessful with trying to find a way to prevent OC from using this.

sebastienros commented 2 years ago

Thanks for confirming, we need to find someone to debug this. If you want to start the investigation on your side you could add a break point in the REDIS services and see what is invoking it even though the feature is not enabled.

I find it weird though that Orchard is able to store something on Redis if you haven't configured it. How can it be that clever to find your instance? Have you checked OC's configuration files to be sure there isn't any config there?

jtkech commented 2 years ago

Yes we have services that inject IDistributedCachewhich by default is a MemoryDistributedCache, same interface but memory only. For example the document manager and the dynamic cache.

Then the redis cache feature is to provide a concrete implementation of a distributed cache, but could be any other feature e.g. providing a cache from a shared database. So yes if you register at the tenant level a custom IDistributedCache it will then be used.

Idem e.g. if you use the aspnetcore Distributed cache tag helper that will use any current implementation of IDistributedCache.

jtkech commented 2 years ago

Hmm, maybe one solution would be to register at the tenant level your distributed cache before we register the MemoryDistributedCache so that our services will resolve this last one, we have a startup Order property to control the registrations order at the tenant/modules level.

Then in your code you could inject an IEnumerable<IDistributedCache> and then only keep your type or filter out the MemoryDistributedCache.

kgwadu commented 2 years ago

@sebastienros @jtkech ok so it sounds like the issue is this "So yes if you register at the tenant level a custom IDistributedCache it will then be used.", will try your suggestion regarding order. Thank you.

jtkech commented 2 years ago

The default Order value is 0, so normally a value of -1 would be sufficient.