How does PropExecutor handle orders that arrive at the same time?

Quick answer

Each order takes a per-account lock and is checked and written inside one database transaction, with open positions read from the database in that transaction. Simultaneous orders on the same account are therefore processed one after another, and limits such as maximum positions hold, even across server instances.

Detailed answer

Concurrency bugs are a classic way for rule limits to fail silently.

The problem

Two orders placed at the same moment can both be checked against the same state. If each sees four open positions under a limit of five, both pass, and the account ends with six.

PropExecutor's approach

  1. Take an advisory lock for the account inside the transaction.
  2. Read open positions and equity from the database.
  3. Run every order-time rule and the margin check.
  4. Write the order, or refuse it.
  5. Commit, releasing the lock.

Every path

Market orders, pending order placement and changes, stop changes and pending orders triggering all use this order gate. The gate fails closed: a path that cannot be checked is refused.

Across instances

Because the lock is in the database, it works whichever server instance receives each order.

Effect on traders

Traders see consistent results: an order is either accepted within the limits or refused with a reason. Under normal conditions the lock is held for a very short time, so it does not slow trading noticeably.

PropExecutor team · Updated

All 11 questions in Security, data and reliability · Every category