Skip to content
Artwork for Programming Tech Brief By HackerNoon
Programming Tech Brief By HackerNoon · Saturday · 6 min

Implementing Transactional API Idempotency With Node.js and PostgreSQL

This story was originally published on HackerNoon at: https://hackernoon.com/implementing-transactional-api-idempotency-with-nodejs-and-postgresql. With idempotency keys in Redis, a crash can still charge twice. Keep the key in the same Postgres transaction as the write (Node.js) so a crash rolls back both. Check more stories related to programming at: https://hackernoon.com/c/programming. You can also check exclusive content about #api-development, #transactional-idempotency, #postgresql, #nodejs, #idempotency-keys, #redis-distributed-locks, #api-retry-mechanisms, #hackernoon-top-story, and more. This story was written by: @dmatoso. Learn more about this writer by checking @dmatoso's about page, and for more stories, please visit hackernoon.com. A Redis idempotency store can still charge a customer twice if the server dies between the write and saving the response. I reproduce the double charge, then move the key into the same Postgres transaction as the payment, so a crash rolls back both.

0:00-6:55

transcript

No transcript — this publisher did not publish one.

show notes

This story was originally published on HackerNoon at: https://hackernoon.com/implementing-transactional-api-idempotency-with-nodejs-and-postgresql.
With idempotency keys in Redis, a crash can still charge twice. Keep the key in the same Postgres transaction as the write (Node.js) so a crash rolls back both.
Check more stories related to programming at: https://hackernoon.com/c/programming. You can also check exclusive content about #api-development, #transactional-idempotency, #postgresql, #nodejs, #idempotency-keys, #redis-distributed-locks, #api-retry-mechanisms, #hackernoon-top-story, and more.

This story was written by: @dmatoso. Learn more about this writer by checking @dmatoso's about page, and for more stories, please visit hackernoon.com.

A Redis idempotency store can still charge a customer twice if the server dies between the write and saving the response. I reproduce the double charge, then move the key into the same Postgres transaction as the payment, so a crash rolls back both.

links13