-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds transaction with watched key example script. #2297
Conversation
* Use meaningful example data, let's not use `foo`, `bar`, `baz` etc! | ||
* Leave an empty line at the end of your `.js` file | ||
* Update this `README.md` file to add your example to the table | ||
- Add your code in a single JavaScript or TypeScript file per example, directly in the `examples` folder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to change anything in this README.md
at all except for adding a new line entry in the table for your new script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sailingwithsandeep please see @simonprickett's question above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonprickett Hey so sorry i just realised i changed the order of readme file's coding guidelines list. it happened because i copied that readme file from previous pull request and somehow changed the order. i hope you understand my concern. Again extremely sorry for changing unwanted things. (P.S. I am so excited that i am contributing into redis community so, given that state i might have rushed it.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't rush @sailingwithsandeep and only change the things that are necessary :) please change it back and we will re-review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonprickett @SuzeShardlow Hey i committed the changes hopefully this time there won't be an issue. Again sorry for the trouble.
Codecov ReportBase: 95.85% // Head: 95.85% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #2297 +/- ##
=======================================
Coverage 95.85% 95.85%
=======================================
Files 433 433
Lines 4002 4002
Branches 451 451
=======================================
Hits 3836 3836
Misses 102 102
Partials 64 64 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sailingwithsandeep I was able to test the happy path successfully, however if there's concurrent modification of paymentId:1259
the code errors like this:
$ node transaction-with-watch.js
Transaction Failed Due To Concurrent Modification!
Error: Error: pool is draining and cannot accept work`
to reproduce this, add a delay between the watch
and exec
during which you change the value stored at paymentId:1259
in a redis-cli
session.
I added the delay using some temporary code that allows me time to modify the key in redis-cli
:
async function slowDown() {
return new Promise(resolve => setTimeout(resolve, 5000));
}
and called it like this:
const multi = isolatedClient
.multi()
.set('paymentId:1259', 'Payment Successfully Completed!')
.set('paymentId:1260', 'Refund Processed Successfully!');
await slowDown();
await multi.exec();
Hello @simonprickett , i have added the delay which you have mentioned in previous review! |
@sailingwithsandeep you still need to look at your code. The delay which @simonprickett mentioned was purely to reproduce / demonstrate the error. It isn't a fix. You still need to fix the error. Please have another read of Simon's comment: #2297 (review) and amend your PR accordingly so the error no longer occurs. |
Hello, @SuzeShardlow @simonprickett i have handled that pooling error please have a look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - both cases (concurrent modification and success) work for me, @SuzeShardlow this is good to merge.
Thanks for your contribution @sailingwithsandeep :) |
@SuzeShardlow @simonprickett Thank you! for supporting me! this was my first open source contribution. |
Welcome to the open source world 🙂 |
My pull request is about creating an example of redis transactions which shows a sample code that runs in isolated connection and provides optimistic locking with check-and-set (CAS) behavior.
#2280
Checklist
npm test
pass with this change (including linting)?