1
0
Fork 0
mirror of synced 2024-09-28 15:21:28 +12:00

Merge pull request #6883 from Budibase/fix/quota-409s

Ignore harmless 409s in write-through cache
This commit is contained in:
Andrew Kingston 2022-07-25 14:58:23 +01:00 committed by GitHub
commit 8b165ca8cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -1,5 +1,6 @@
import BaseCache from "./base"
import { getWritethroughClient } from "../redis/init"
import { logWarn } from "../logging"
const DEFAULT_WRITE_RATE_MS = 10000
let CACHE: BaseCache | null = null
@ -51,10 +52,8 @@ export async function put(
if (err.status !== 409) {
throw err
} else {
// get the rev, update over it - this is risky, may change in future
const readDoc = await db.get(doc._id)
doc._rev = readDoc._rev
await writeDb(doc)
// Swallow 409s but log them
logWarn(`Ignoring conflict in write-through cache`)
}
}
}

View file

@ -15,6 +15,11 @@ export function logAlert(message: string, e?: any) {
console.error(`bb-alert: ${message} ${errorJson}`)
}
export function logWarn(message: string) {
console.warn(`bb-warn: ${message}`)
}
export default {
logAlert,
logWarn,
}