quit fails to clean up when using multi
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.6k
- Forks
- 2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 40
Description
~ $ node -v
v10.1.0
~ $ redis-server --version
Redis server v=3.0.6 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=687a2a319020fa42
~ $ lsb_release -a
LSB Version: core-9.20160110ubuntu0.2-amd64:core-9.20160110ubuntu0.2-noarch:printing-9.20160110ubuntu0.2-amd64:printing-9.20160110ubuntu0.2-noarch:security-9.20160110ubuntu0.2-amd64:security-9.20160110ubuntu0.2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
Trying to get my head around the redis transaction stuff in order to support atomic events on small (json) objects (ratoms) using watch/multi. The initial code is working but client.quit() doesn't clean up any more:
const newRAtom = (ratom) => {
const key = getRAtomKey(ratom);
return new Promise((resolve, reject) => {
const transaction = client.multi();
transaction.watch(key);
client.get(key, (err, value) => {
if (err) reject(err);
if (value) reject(key + ' already exists');
else {
transaction.set(key, stringify(ratom));
transaction.exec((err) => {
if (err) reject(err);
else resolve(ratom)})}})})};
My theory is that the transaction (multi) ensures that other processes can't create a matching ratom in redis. This works in testing but once the above function has been used client.quit() fails to clean up the client so the javascript tests fail to terminate until -c is used to force an exit. This happens when the newRAtom promise resolves so transaction.exec has been called (and redis monitor shows the expected updates).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported sequence with client.multi(), transaction.watch(), transaction.exec(), and client.quit() on the stated Node.js, Redis, and Ubuntu versions. Trace whether the transaction or watched connection remains active after exec; done means the promise resolves and client.quit() lets the test process terminate without Ctrl-C.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, redis
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100