How a Database Server Starts, Handles, and Completes Client Requests
The article outlines the step‑by‑step lifecycle of a database server—from system initialization and buffer allocation, through connection and thread management, request parsing, optimization, storage‑engine interaction, to final response delivery and cleanup—illustrated with diagrams of each stage.
Startup
The initialization module reads system parameters and command‑line arguments, sets up the entire system—such as allocating buffers and initializing global variables—and starts each storage engine.
After startup completes, control is handed to the connection management module, which launches a port‑listening service ready to accept client requests.
Receive Request
When the connection management module receives a client request, it communicates according to the interaction protocol and then passes the connection request to the thread management module to obtain a thread.
The thread management module first performs an authorization check; if authorized, it checks the connection thread pool for a cached idle thread. If one exists, it is assigned to the client request; otherwise, a new connection thread is created.
Process Request
After the client request is paired with a connection thread, request processing begins.
If the client request is a query, it is handed to the query parser, which first determines whether it is a SELECT statement. For SELECTs, the cache query module is invoked; if the result is cached, the data is returned directly to the connection thread and sent to the client. Otherwise, the parser dispatches the request to the appropriate modules.
Uncached SELECTs are passed to the optimizer module; if the request involves table content or structural changes, it goes to the table‑change management module; updates to statistics, checks, repairs, or reorganizations are handled by the table maintenance module; replication‑related requests are sent to the replication module; and status‑collection requests are handled by the status‑report module.
Each module, upon receiving a request, first verifies whether the user has permission for the target table; if so, it checks whether the table is present in the table cache. If not cached, the table is opened and the appropriate lock is acquired.
When the table‑change management module opens a table, it examines the table’s metadata to determine the storage‑engine type and other relevant information, then invokes the corresponding storage‑engine interface for processing.
Complete Request
The connection thread module returns the processing result to the client, performs the necessary cleanup, and then waits for subsequent requests.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
