Skip to content

MainThread

Xiahua Liu edited this page Jan 27, 2025 · 4 revisions

Main Thread

PawnDB’s main thread listens on the server UDP socket and manages transaction lifecycles.

Start A New Transaction

When the main thread receives a start transaction message, it cleans up dead transactions, checks the worker thread table, and either:

  • Returns a busy error if the table is full
  • Or creates a new WorkerContext and starts a worker thread.

Other Operations

For other operations, the main thread routes requests to the correct worker.

If the operation is ABORT, it sets the thread’s running flag to false.

Once the worker exits, it sends its transaction ID back, and the main thread joins the thread before accepting another transaction.

Clone this wiki locally