Reverting try twice change to writethrough.
This commit is contained in:
parent
5249148d6c
commit
99607ca06e
|
@ -73,25 +73,15 @@ describe("writethrough", () => {
|
||||||
])
|
])
|
||||||
|
|
||||||
// with a lock, this will work
|
// with a lock, this will work
|
||||||
const revs = responses.map(x => x.rev)
|
const newRev = responses.map(x => x.rev).find(x => x !== current._rev)
|
||||||
const startWith = ["3", "4", "5"]
|
expect(newRev).toBeDefined()
|
||||||
const found = []
|
expect(responses.map(x => x.rev)).toEqual(
|
||||||
let maxRev
|
expect.arrayContaining([current._rev, current._rev, newRev])
|
||||||
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 output = await db.get(current._id)
|
const output = await db.get(current._id)
|
||||||
expect(output.value).toBe(4)
|
expect(output.value).toBe(4)
|
||||||
expect(output._rev).toBe(maxRev)
|
expect(output._rev).toBe(newRev)
|
||||||
|
|
||||||
current = output
|
current = output
|
||||||
})
|
})
|
||||||
|
|
|
@ -44,7 +44,7 @@ async function put(
|
||||||
if (updateDb) {
|
if (updateDb) {
|
||||||
const lockResponse = await locks.doWithLock(
|
const lockResponse = await locks.doWithLock(
|
||||||
{
|
{
|
||||||
type: LockType.TRY_TWICE,
|
type: LockType.TRY_ONCE,
|
||||||
name: LockName.PERSIST_WRITETHROUGH,
|
name: LockName.PERSIST_WRITETHROUGH,
|
||||||
resource: key,
|
resource: key,
|
||||||
ttl: 15000,
|
ttl: 15000,
|
||||||
|
|
|
@ -122,7 +122,6 @@ export async function doWithLock<T>(
|
||||||
if (opts.type === LockType.TRY_ONCE) {
|
if (opts.type === LockType.TRY_ONCE) {
|
||||||
// don't throw for try-once locks, they will always error
|
// don't throw for try-once locks, they will always error
|
||||||
// due to retry count (0) exceeded
|
// due to retry count (0) exceeded
|
||||||
console.warn(e)
|
|
||||||
return { executed: false }
|
return { executed: false }
|
||||||
} else {
|
} else {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
|
Loading…
Reference in New Issue