MYSQL The Server Shutdown Process(筆記)
The server shutdown process takes place as follows:
-
The shutdown process is initiated.
This can occur initiated several ways. For example, a user with the privilege can execute a command. can be used on any platform supported by MySQL. Other operating system-specific shutdown initiation methods are possible as well: The server shuts down on Unix when it receives a
SIGTERM
signal. A server running as a service on Windows shuts down when the services manager tells it to. -
The server creates a shutdown thread if necessary.
Depending on how shutdown was initiated, the server might create a thread to handle the shutdown process. If shutdown was requested by a client, a shutdown thread is created. If shutdown is the result of receiving a
SIGTERM
signal, the signal thread might handle shutdown itself, or it might create a separate thread to do so. If the server tries to create a shutdown thread and cannot (for example, if memory is exhausted), it issues a diagnostic message that appears in the error log:Error: Can't create thread to kill server
-
The server stops accepting new connections.
To prevent new activity from being initiated during shutdown, the server stops accepting new client connections by closing the handlers for the network interfaces to which it normally listens for connections: the TCP/IP port, the Unix socket file, the Windows named pipe, and shared memory on Windows.
-
The server terminates current activity.
For each thread associated with a client connection, the server breaks the connection to the client and marks the thread as killed. Threads die when they notice that they are so marked. Threads for idle connections die quickly. Threads that currently are processing statements check their state periodically and take longer to die. For additional information about thread termination, see , in particular for the instructions about killed or operations on
MyISAM
tables.For threads that have an open transaction, the transaction is rolled back. If a thread is updating a nontransactional table, an operation such as a multiple-row or may leave the table partially updated because the operation can terminate before completion.
If the server is a replication source server, it treats threads associated with currently connected replicas like other client threads. That is, each one is marked as killed and exits when it next checks its state.
If the server is a replica server, it stops the replication I/O and SQL threads, if they are active, before marking client threads as killed. The SQL thread is permitted to finish its current statement (to avoid causing replication problems), and then stops. If the SQL thread is in the middle of a transaction at this point, the server waits until the current replication event group (if any) has finished executing, or until the user issues a or statement. See also . Since nontransactional statements cannot be rolled back, in order to guarantee crash-safe replication, only transactional tables should be used.
NoteTo guarantee crash safety on the replica, you must run the replica with enabled.
See also ).
-
The server shuts down or closes storage engines.
At this stage, the server flushes the table cache and closes all open tables.
Each storage engine performs any actions necessary for tables that it manages.
InnoDB
flushes its buffer pool to disk (unless is 2), writes the current LSN to the tablespace, and terminates its own internal threads.MyISAM
flushes any pending index writes for a table. -
The server exits.
To provide information to management processes, the server returns one of the exit codes described in the following list. The phrase in parentheses indicates the action taken by systemd in response to the code, for platforms on which systemd is used to manage the server.
-
0 = successful termination (no restart done)
-
1 = unsuccessful termination (no restart done)
-
2 = unsuccessful termination (restart done)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29863023/viewspace-2838100/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 8.0 Reference Manual(讀書筆記61節--Examining Server Thread (Process) Information(2))MySql筆記ServerthreadORM
- MySQL 8.0 Reference Manual(讀書筆記61節--Examining Server Thread (Process) Information(1))MySql筆記ServerthreadORM
- MySQL報錯Slave: received end packet from server, apparent master shutdownMySqlServerAPPAST
- SQL-Server筆記SQLServer筆記
- vCenter Server使用筆記Server筆記
- MySQL 8.0 Reference Manual(讀書筆記60節--Optimizing the MySQL Server 和 Measuring Performance)MySql筆記ServerORM
- (十五) 學習筆記: Python程式(Process)相關筆記Python
- Mysql 筆記MySql筆記
- MySQL筆記MySql筆記
- MySQL 8.0 Reference Manual(讀書筆記77節--Merge Threshold for Index Pages & Automatic Configuration for a Dedicated MySQL Server)MySql筆記IndexServer
- Mysql 工作筆記MySql筆記
- MySql索引筆記MySql索引筆記
- mysql CRUD筆記MySql筆記
- MySQL資料庫innodb_fast_shutdown引數MySql資料庫AST
- MySQL 優化筆記MySql優化筆記
- MySQL基礎筆記MySql筆記
- MySql學習筆記MySql筆記
- 【記錄】MySQL 學習筆記MySql筆記
- [記錄] MySQL 學習筆記MySql筆記
- MySQL 筆記 - 索引優化MySql筆記索引優化
- MySQL 筆記 - 事務&鎖MySql筆記
- MySql學習筆記06MySql筆記
- MySQL 最佳化筆記MySql筆記
- mysql學習筆記3MySql筆記
- MySQL高階篇筆記MySql筆記
- 筆記:Mysql踩坑之路筆記MySql
- MySQL筆記 13 檢視MySql筆記
- MySQL學習筆記:鎖MySql筆記
- MySQL學習筆記2MySql筆記
- leanote螞蟻雲筆記arm_server搭建筆記Server
- [學習筆記]SQL server完全備份指南筆記SQLServer
- MySQL提升筆記(1):MySQL邏輯架構MySql筆記架構
- MySQL學習筆記之一MySql筆記
- mysql8.0學習筆記MySql筆記
- MySQL資料型別筆記MySql資料型別筆記
- mysql必知必會筆記MySql筆記
- MySQL學習筆記:索引失效MySql筆記索引
- mysql總結筆記 -- 索引篇MySql筆記索引