blog

Simple way to check for race conditions

17 May 2016

Today was a fun day. We were working on a piece of code which interacts with PostgreSQL database. One function was reading from database and based on the query result it inserted some data afterwards. The thing is that it wasn’t done in a transaction so I suspected there could be a race condition. But how to test such case?

My requirements for such test were obvious: I wanna spam the server with streams of requests and check logs if the server is able to handle it. Pretty easy to do in shell: