graphiti-api / graphiti

Stylish Graph APIs
https://www.graphiti.dev/
MIT License
974 stars 139 forks source link

Multi-tenant app returns other tenant data in sideload #383

Closed mozcomp closed 2 years ago

mozcomp commented 3 years ago

We're using graphiti as an API to access a multi-tenanted app using Apartment, where each request can change the MYSQL schema being used.

It seems that side-loading can include another tenant's data, I assume because of caching.

To use caching in this environment we'd need to include the schema name in the cache, but possibly easier to turn caching off.

Any thoughts?

wadetandy commented 3 years ago

Top of my head would be that this could be related to concurrency. If apartment uses Thread.current to store the tenant under the hood, then it wouldn't be set while doing sideloads with concurrency enabled. Disable with

Graphiti.configure do |config|
  config.concurrency = false
end

If that works then things will slow down a bit but your data will stay correct.

mozcomp commented 3 years ago

Thanks for the quick reply Wade, concurrency already set to false

On Wed, 1 Sept 2021 at 13:52, Wade Tandy @.***> wrote:

Top of my head would be that this could be related to concurrency. If apartment uses Thread.current to store the tenant under the hood, then it wouldn't be set while doing sideloads with concurrency enabled. Disable with

Graphiti.configure do |config| config.concurrency = falseend

If that works then things will slow down a bit but your data will stay correct.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/graphiti-api/graphiti/issues/383#issuecomment-909853656, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSWVCQRAJ2TTATSEUTTBLT7WPONANCNFSM5DFOELOQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

richmolj commented 3 years ago

Hard to say with concurrency off...we don't have any other cache in Graphiti so if it's not concurency I'm not sure what is happening. Not familiar with Apartment, sorry :(