-
Notifications
You must be signed in to change notification settings - Fork 0
MainThread
Xiahua Liu edited this page Jan 27, 2025
·
4 revisions
PawnDB’s main thread listens on the server UDP socket and manages transaction lifecycles.
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
WorkerContextand starts a worker thread.
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.