Reverting try twice change to writethrough.

This commit is contained in:
Michael Drury 2023-05-30 20:45:10 +01:00
parent 5249148d6c
commit 99607ca06e
3 changed files with 7 additions and 18 deletions

View File

@ -73,25 +73,15 @@ describe("writethrough", () => {
])
// with a lock, this will work
const revs = responses.map(x => x.rev)
const startWith = ["3", "4", "5"]
const found = []
let maxRev
for (let starting of startWith) {
for (let rev of revs) {
if (rev?.startsWith(starting)) {
found.push(starting)
}
if (rev?.startsWith("5")) {
maxRev = rev
}
}
}
expect(found.length).toBe(3)
const newRev = responses.map(x => x.rev).find(x => x !== current._rev)
expect(newRev).toBeDefined()
expect(responses.map(x => x.rev)).toEqual(
expect.arrayContaining([current._rev, current._rev, newRev])
)
const output = await db.get(current._id)
expect(output.value).toBe(4)
expect(output._rev).toBe(maxRev)
expect(output._rev).toBe(newRev)
current = output
})

View File

@ -44,7 +44,7 @@ async function put(
if (updateDb) {
const lockResponse = await locks.doWithLock(
{
type: LockType.TRY_TWICE,
type: LockType.TRY_ONCE,
name: LockName.PERSIST_WRITETHROUGH,
resource: key,
ttl: 15000,

View File

@ -122,7 +122,6 @@ export async function doWithLock<T>(
if (opts.type === LockType.TRY_ONCE) {
// don't throw for try-once locks, they will always error
// due to retry count (0) exceeded
console.warn(e)
return { executed: false }
} else {
console.error(e)