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(multitenancy): add a fallback for get commands in redis #7043

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dracarys18
Copy link
Member

@dracarys18 dracarys18 commented Jan 16, 2025

Type of Change

  • Enhancement

Description

  • Add a fallback for Redis gets with prefix
  • Add a Domain type for Redis for the correctness of adding a prefix

Motivation and Context

To keep the tenant data isolated from each other, We are using a prefix for Redis keys i.e A key which would be saved as card123 without multitenancy would be saved as public:card123 with Multitenancy.
If the user makes a payment on the older pod where MultiTenancy is disabled and client_secret is saved without a prefix, Now if the confirm calls goes to the pod where Multitenancy is enabled the Payment would fail with Unauthorized. This is just one of the instances where the payments would fail.

How did you test it?

** THIS CANNOT BE TESTED ON HIGHER ENVIRONMENTS **

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code

@dracarys18 dracarys18 added the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jan 16, 2025
@dracarys18 dracarys18 added this to the December 2024 Release milestone Jan 16, 2025
@dracarys18 dracarys18 self-assigned this Jan 16, 2025
@dracarys18 dracarys18 requested review from a team as code owners January 16, 2025 10:01
Copy link

semanticdiff-com bot commented Jan 16, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/services/authorization.rs  97% smaller
  crates/router/src/routes/payment_methods.rs  95% smaller
  crates/router/src/core/payments/types.rs  95% smaller
  crates/router/src/core/api_locking.rs  93% smaller
  crates/router/src/core/payment_methods/vault.rs  92% smaller
  crates/storage_impl/src/redis/cache.rs  92% smaller
  crates/storage_impl/src/redis/kv_store.rs  89% smaller
  crates/router/src/core/poll.rs  83% smaller
  crates/drainer/src/stream.rs  81% smaller
  crates/router/src/core/health_check.rs  75% smaller
  crates/scheduler/src/utils.rs  75% smaller
  crates/router/src/core/payment_methods/cards.rs  72% smaller
  crates/router/src/utils/currency.rs  68% smaller
  crates/router/src/db/ephemeral_key.rs  68% smaller
  crates/scheduler/src/db/queue.rs  64% smaller
  crates/drainer/src/health_check.rs  62% smaller
  crates/router/src/services/authentication/blacklist.rs  56% smaller
  crates/router/src/routes/dummy_connector/utils.rs  47% smaller
  crates/router/src/core/payments/helpers.rs  26% smaller
  crates/redis_interface/src/commands.rs  25% smaller
  crates/router/src/core/payouts/helpers.rs  24% smaller
  crates/router/src/services/openidconnect.rs  17% smaller
  crates/router/src/utils/user/two_factor_auth.rs  17% smaller
  crates/router/src/db/merchant_connector_account.rs  17% smaller
  crates/router/src/core/payments.rs  16% smaller
  crates/router/src/utils/user.rs  16% smaller
  crates/router/src/core/pm_auth.rs  9% smaller
  crates/redis_interface/Cargo.toml Unsupported file format
  crates/redis_interface/src/types.rs  0% smaller
  crates/router/src/core/payments/operations/payment_confirm.rs  0% smaller
  crates/router/src/core/webhooks/incoming.rs  0% smaller
  crates/router/src/routes/dummy_connector/core.rs  0% smaller
  crates/router/tests/cache.rs  0% smaller
  crates/storage_impl/src/lib.rs  0% smaller

@dracarys18 dracarys18 linked an issue Jan 16, 2025 that may be closed by this pull request
@dracarys18 dracarys18 requested review from a team as code owners January 21, 2025 07:15
@dracarys18 dracarys18 force-pushed the add_fallback_for_redis_prefix_get branch from 75b41f7 to e31f032 Compare January 21, 2025 07:17
@dracarys18 dracarys18 removed request for a team January 21, 2025 07:18
@dracarys18 dracarys18 added the A-core Area: Core flows label Jan 21, 2025
jarnura
jarnura previously approved these changes Jan 21, 2025
racnan
racnan previously approved these changes Jan 21, 2025
Copy link
Contributor

@Chethan-rao Chethan-rao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also why are none of the stream redis commands not having this fallback logic?

crates/redis_interface/src/commands.rs Outdated Show resolved Hide resolved
crates/redis_interface/src/commands.rs Outdated Show resolved Hide resolved
@dracarys18
Copy link
Member Author

Also why are none of the stream redis commands not having this fallback logic?

Retrying streams is a little tricky because xread will not throw any error if the stream is empty obviously. And in this case the streams with prefix will mostly be empty. And only way to retry it is to drain from both the streams. And I am not sure what sort of problems that could come with it. So I think it's better to do that consciously rather than trying it in the code.

@likhinbopanna likhinbopanna added this pull request to the merge queue Jan 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows S-waiting-on-review Status: This PR has been implemented and needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FIX] add a fallback to key without prefix for redis
5 participants