Browse Source
Merge pull request #6883 from Budibase/fix/quota-409s
Ignore harmless 409s in write-through cache
master
Andrew Kingston
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
8 additions and
4 deletions
-
packages/backend-core/src/cache/writethrough.ts
-
packages/backend-core/src/logging.ts
|
|
@ -1,5 +1,6 @@ |
|
|
import BaseCache from "./base" |
|
|
import BaseCache from "./base" |
|
|
import { getWritethroughClient } from "../redis/init" |
|
|
import { getWritethroughClient } from "../redis/init" |
|
|
|
|
|
import { logWarn } from "../logging" |
|
|
|
|
|
|
|
|
const DEFAULT_WRITE_RATE_MS = 10000 |
|
|
const DEFAULT_WRITE_RATE_MS = 10000 |
|
|
let CACHE: BaseCache | null = null |
|
|
let CACHE: BaseCache | null = null |
|
|
@ -51,10 +52,8 @@ export async function put( |
|
|
if (err.status !== 409) { |
|
|
if (err.status !== 409) { |
|
|
throw err |
|
|
throw err |
|
|
} else { |
|
|
} else { |
|
|
// get the rev, update over it - this is risky, may change in future
|
|
|
// Swallow 409s but log them
|
|
|
const readDoc = await db.get(doc._id) |
|
|
logWarn(`Ignoring conflict in write-through cache`) |
|
|
doc._rev = readDoc._rev |
|
|
|
|
|
await writeDb(doc) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
@ -15,6 +15,11 @@ export function logAlert(message: string, e?: any) { |
|
|
console.error(`bb-alert: ${message} ${errorJson}`) |
|
|
console.error(`bb-alert: ${message} ${errorJson}`) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function logWarn(message: string) { |
|
|
|
|
|
console.warn(`bb-warn: ${message}`) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
logAlert, |
|
|
logAlert, |
|
|
|
|
|
logWarn, |
|
|
} |
|
|
} |
|
|
|