Browse Source

Merge pull request #7504 from nocodb/nc-fix/redis-missing

fix: fallback for missing list key
pull/7499/head
Mert E 10 months ago committed by GitHub
parent
commit
75959ff142
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 22
      packages/nocodb/src/cache/RedisCacheMgr.ts
  2. 24
      packages/nocodb/src/cache/RedisMockCacheMgr.ts

22
packages/nocodb/src/cache/RedisCacheMgr.ts vendored

@ -169,6 +169,28 @@ export default class RedisCacheMgr extends CacheMgr {
log(`RedisCacheMgr::getList: getting list with keys ${arr}`); log(`RedisCacheMgr::getList: getting list with keys ${arr}`);
const values = await this.client.mget(arr); const values = await this.client.mget(arr);
if (values.some((v) => v === null)) {
// FALLBACK: a key is missing from list, this should never happen
console.error(`RedisCacheMgr::getList: missing value for ${key}`);
const allParents = [];
// get all parents from children
values.forEach((v) => {
allParents.push(...this.getParents(v));
});
// remove duplicates
const uniqueParents = [...new Set(allParents)];
// delete all parents and children
await Promise.all(
uniqueParents.map(async (p) => {
await this.deepDel(scope, p, CacheDelDirection.PARENT_TO_CHILD);
}),
);
return Promise.resolve({
list: [],
isNoneList,
});
}
return { return {
list: values.map((res) => { list: values.map((res) => {
try { try {

24
packages/nocodb/src/cache/RedisMockCacheMgr.ts vendored

@ -163,9 +163,31 @@ export default class RedisMockCacheMgr extends CacheMgr {
}); });
} }
log(`RedisCacheMgr::getList: getting list with keys ${arr}`); log(`RedisMockCacheMgr::getList: getting list with keys ${arr}`);
const values = await this.client.mget(arr); const values = await this.client.mget(arr);
if (values.some((v) => v === null)) {
// FALLBACK: a key is missing from list, this should never happen
console.error(`RedisMockCacheMgr::getList: missing value for ${key}`);
const allParents = [];
// get all parents from children
values.forEach((v) => {
allParents.push(...this.getParents(v));
});
// remove duplicates
const uniqueParents = [...new Set(allParents)];
// delete all parents and children
await Promise.all(
uniqueParents.map(async (p) => {
await this.deepDel(scope, p, CacheDelDirection.PARENT_TO_CHILD);
}),
);
return Promise.resolve({
list: [],
isNoneList,
});
}
return { return {
list: values.map((res) => { list: values.map((res) => {
try { try {

Loading…
Cancel
Save