fix(multitenancy): add a fallback for get commands in redis (#7043)

This commit is contained in:
Kartikeya Hegde
2025-01-29 00:38:17 +05:30
committed by GitHub
parent 858866f9f3
commit 5707297621
34 changed files with 362 additions and 204 deletions

View File

@ -256,7 +256,7 @@ impl<T: DatabaseStore> KVRouterStore<T> {
.cache_store
.redis_conn
.stream_append_entry(
&stream_name,
&stream_name.into(),
&redis_interface::RedisEntryId::AutoGeneratedID,
redis_entry
.to_field_value_pairs(request_id, global_id)
@ -309,7 +309,7 @@ pub trait UniqueConstraints {
let constraints = self.unique_constraints();
let sadd_result = redis_conn
.sadd(
&format!("unique_constraint:{}", self.table_name()),
&format!("unique_constraint:{}", self.table_name()).into(),
constraints,
)
.await?;

View File

@ -299,11 +299,13 @@ where
{
let type_name = std::any::type_name::<T>();
let key = key.as_ref();
let redis_val = redis.get_and_deserialize_key::<T>(key, type_name).await;
let redis_val = redis
.get_and_deserialize_key::<T>(&key.into(), type_name)
.await;
let get_data_set_redis = || async {
let data = fun().await?;
redis
.serialize_and_set_key(key, &data)
.serialize_and_set_key(&key.into(), &data)
.await
.change_context(StorageError::KVError)?;
Ok::<_, Report<StorageError>>(data)
@ -380,7 +382,7 @@ pub async fn redact_from_redis_and_publish<
let redis_keys_to_be_deleted = keys
.clone()
.into_iter()
.map(|val| val.get_key_without_prefix().to_owned())
.map(|val| val.get_key_without_prefix().to_owned().into())
.collect::<Vec<_>>();
let del_replies = redis_conn

View File

@ -181,7 +181,7 @@ where
logger::debug!(kv_operation= %operation, value = ?value);
redis_conn
.set_hash_fields(&key, value, Some(ttl.into()))
.set_hash_fields(&key.into(), value, Some(ttl.into()))
.await?;
store
@ -193,14 +193,14 @@ where
KvOperation::HGet(field) => {
let result = redis_conn
.get_hash_field_and_deserialize(&key, field, type_name)
.get_hash_field_and_deserialize(&key.into(), field, type_name)
.await?;
Ok(KvResult::HGet(result))
}
KvOperation::Scan(pattern) => {
let result: Vec<T> = redis_conn
.hscan_and_deserialize(&key, pattern, None)
.hscan_and_deserialize(&key.into(), pattern, None)
.await
.and_then(|result| {
if result.is_empty() {
@ -218,7 +218,7 @@ where
value.check_for_constraints(&redis_conn).await?;
let result = redis_conn
.serialize_and_set_hash_field_if_not_exist(&key, field, value, Some(ttl))
.serialize_and_set_hash_field_if_not_exist(&key.into(), field, value, Some(ttl))
.await?;
if matches!(result, redis_interface::HsetnxReply::KeySet) {
@ -235,7 +235,7 @@ where
logger::debug!(kv_operation= %operation, value = ?value);
let result = redis_conn
.serialize_and_set_key_if_not_exist(&key, value, Some(ttl.into()))
.serialize_and_set_key_if_not_exist(&key.into(), value, Some(ttl.into()))
.await?;
value.check_for_constraints(&redis_conn).await?;
@ -251,7 +251,9 @@ where
}
KvOperation::Get => {
let result = redis_conn.get_and_deserialize_key(&key, type_name).await?;
let result = redis_conn
.get_and_deserialize_key(&key.into(), type_name)
.await?;
Ok(KvResult::Get(result))
}
}