oncall-engine/engine/apps/mobile_app
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
..
migrations Fix db migration for mobile app (#3260) 2023-11-02 16:40:26 +00:00
tasks patch redis cluster multi-key operations (#3496) 2023-12-04 13:08:57 -05:00
tests "Going oncall" notification settings (#3187) 2023-10-30 13:44:18 +00:00
__init__.py Mobile app messaging backend (#874) 2022-11-23 15:56:43 +00:00
alert_rendering.py Fix warnings when running backend tests (#2079) 2023-06-06 18:38:00 +00:00
auth.py Return API URL as part of status (#2791) 2023-08-22 17:17:26 +00:00
backend.py rename notify_user_async celery task to notify_user_about_new_alert_group (#2900) 2023-08-29 16:02:09 +02:00
demo_push.py refactor apps.mobile_app.tasks into individual task files (#2888) 2023-08-29 11:34:09 +02:00
exceptions.py Test mobile push (#1933) 2023-05-18 15:52:42 +08:00
fcm_relay.py address mobile device push notification delivery issue when user had > 1 registered device (#2421) 2023-07-05 15:14:46 +00:00
models.py Update wording for mobile push notifications timing choices (#3253) 2023-11-02 11:37:28 +00:00
serializers.py "Going oncall" notification settings (#3187) 2023-10-30 13:44:18 +00:00
types.py Add backend support for push notification sounds with custom extensions (#2759) 2023-08-07 09:55:17 +00:00
urls.py "Going oncall" notification settings (#3187) 2023-10-30 13:44:18 +00:00
utils.py refactor apps.mobile_app.tasks into individual task files (#2888) 2023-08-29 11:34:09 +02:00
views.py "Going oncall" notification settings (#3187) 2023-10-30 13:44:18 +00:00