Skip to content

[Concurrency] Implement Lock-Free Database Connection Pool #502

@somethingwithproof

Description

@somethingwithproof

Problem

Spine uses a global LOCK_POOL mutex to manage access to database connections. In high-concurrency environments (e.g., 32+ threads), this mutex becomes a major contention point as every thread must lock/unlock it twice for every polling item.

Proposed Solution

Refactor db_get_connection and db_release_connection to use lock-free data structures or atomic operations (C11 stdatomic.h) to manage the pool state.

  • Replace the linear search + mutex with an atomic bitmask or a lock-free stack of available connection pointers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions