Skip to content

Commit

Permalink
Failure of transaction with watch should be ignored. (#977)
Browse files Browse the repository at this point in the history
The method `Scheduler.cleanupTimestamp` uses Optimistic locking by watch command, it's quite possible some watched keys changed during transaction (as a result, null is returned), it's OK, scheduler will start next polling, and the failed timestamp will be retried. 

ref: https://redis.io/docs/interact/transactions/#optimistic-locking-using-check-and-set
  • Loading branch information
lopaz authored Aug 12, 2023
1 parent 5ef9737 commit cc0c0de
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,13 @@ export class Scheduler extends EventEmitter {
.del(key)
.zrem(this.connection.key("delayed_queue_schedule"), timestamp)
.exec();

response.forEach((res) => {
if (res[0] !== null) {
throw res[0];
}
});
if (response !== null) {
response.forEach((res) => {
if (res[0] !== null) {
throw res[0];
}
});
}
}
await this.unwatchIfPossible();
}
Expand Down

0 comments on commit cc0c0de

Please sign in to comment.