DEV Community


Posted on

How to sequentially execute a procedure on concurrent requests

We have a web application which is accessed by multiple users concurrently. PostgreSQL is the database for the application.

The core functionality of app is to allocate tickets to the user who hits the "Fetch" button. All the business logics for the button click event are written inside the PostgreSQL Procedure. As said, users will hit the "Fetch" button concurrently.

Business requirement is, when the fetch button is clicked, all the requests to the procedure has to be executed sequentially(like FIFO). The next user's request should be processed only after the completion of previous request(Parallel execution should not be allowed).

How to achieve this within PostgreSQL.

I can install Postgres extensions if required.

Note: I have suggested my team to use message queuing applications to achieve this but they are not willing to rely on any external tools like RabbitMQ or any.

Top comments (0)