Saturday 21 October 2017

[HELP] What is the best practice approach to avoiding race condition database code?

In this specific project I'm using knex.js (postgresql backed) and hapi.js.There are cases where I'm creating resource routes with dependents also created at the time of the request (multiple find or create patterns).I'm passing a transaction down through the calls.It doesn't seem to me that this "looks" good. I haven't seen any actual examples of production transaction code (hell, the only place you even see transactions commonly used are in transaction docs).I feel like I've been spoiled, having worked in the ActiveRecord world.Does anyone have any tips for writing safe database code?NOTE: Parameterized queries, and input scrubbing/validation are not the concern. I'm specifically asking about code that would introduce race bugs.

Submitted October 21, 2017 at 07:49AM by neonlibra

No comments:

Post a Comment