oncall-engine/engine/apps
Joey Orlando 1df1b1eaa0
patch redis cluster multi-key operations (#3496)
# Which issue(s) this PR fixes

Related to https://github.com/grafana/oncall-private/issues/2363

Addresses this issue that arises when using
`cache.get_many`/`cache.set_many` operations with a Redis Cluster:
```python3
File "/usr/local/lib/python3.11/site-packages/redis/cluster.py", line 1006, in determine_slot
    raise RedisClusterException(
redis.exceptions.RedisClusterException: MGET - all keys must map to the same key slot
```

From the Redis Cluster
[docs](https://redis.io/docs/reference/cluster-spec/#hash-tags), this
can be addressed with this 👇 . Basically this will ensure that keys in
multi-key operations will resolve to the same hash slot (read: node):

> Hash tags
> There is an exception for the computation of the hash slot that is
used in order to implement hash tags. Hash tags are a way to ensure that
multiple keys are allocated in the same hash slot. This is used in order
to implement multi-key operations in Redis Cluster.
> 
> To implement hash tags, the hash slot for a key is computed in a
slightly different way in certain conditions. If the key contains a
"{...}" pattern only the substring between { and } is hashed in order to
obtain the hash slot. However since it is possible that there are
multiple occurrences of { or } the algorithm is well specified by the
following rules:
> 
> IF the key contains a { character.
> AND IF there is a } character to the right of {.
> AND IF there are one or more characters between the first occurrence
of { and the first occurrence of }.
> Then instead of hashing the key, only what is between the first
occurrence of { and the following first occurrence of } is hashed.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-12-04 13:08:57 -05:00
..
alerts Revert "upgrade to Python 3.12 (#3456)" and "bump uwsgi version to latest #3466" (#3483) 2023-12-01 09:56:26 -05:00
api Disallow creating and deleting direct paging integrations (#3475) 2023-12-04 13:13:53 +00:00
api_for_grafana_incident Add render_for_web information to alert group incident API (#3005) 2023-09-12 12:02:42 +00:00
auth_token Change service account auth to use instance id instead (#3435) 2023-11-28 15:56:29 +00:00
base Revert "upgrade to Python 3.12 (#3456)" and "bump uwsgi version to latest #3466" (#3483) 2023-12-01 09:56:26 -05:00
email Minor formatting changes (#2641) 2023-07-26 14:45:44 +01:00
grafana_plugin Refactor gcom api calls when syncing org (#3489) 2023-12-04 13:08:59 +00:00
heartbeat Update transaction.on_commit to use partial instead of lambda (#3448) 2023-11-29 12:01:30 +00:00
integrations Add test ensuring integration endpoints work if redis cache is down (#3445) 2023-12-01 17:45:18 +00:00
labels Skip empty alert group labels (#3495) 2023-12-04 13:46:03 +00:00
metrics_exporter patch redis cluster multi-key operations (#3496) 2023-12-04 13:08:57 -05:00
mobile_app patch redis cluster multi-key operations (#3496) 2023-12-04 13:08:57 -05:00
oss_installation Revert "upgrade to Python 3.12 (#3456)" and "bump uwsgi version to latest #3466" (#3483) 2023-12-01 09:56:26 -05:00
phone_notifications Revert "upgrade to Python 3.12 (#3456)" and "bump uwsgi version to latest #3466" (#3483) 2023-12-01 09:56:26 -05:00
public_api Disallow creating and deleting direct paging integrations (#3475) 2023-12-04 13:13:53 +00:00
schedules patch redis cluster multi-key operations (#3496) 2023-12-04 13:08:57 -05:00
slack Revert "upgrade to Python 3.12 (#3456)" and "bump uwsgi version to latest #3466" (#3483) 2023-12-01 09:56:26 -05:00
social_auth Enable flake8-bugbear, fix issues (#3454) 2023-11-29 15:04:48 +00:00
telegram Make telegram on_alert_group_action_triggered asynchronous (#3471) 2023-12-01 10:49:00 +00:00
twilioapp add missing db migrations + add additional backend db migration check to CI (#3234) 2023-10-31 16:00:55 -04:00
user_management Refactor gcom api calls when syncing org (#3489) 2023-12-04 13:08:59 +00:00
webhooks Enable flake8-bugbear, fix issues (#3454) 2023-11-29 15:04:48 +00:00
zvonok add missing db migrations + add additional backend db migration check to CI (#3234) 2023-10-31 16:00:55 -04:00
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00