MySQL Internal 筆記

來源:互聯網
上載者:User

主要模組的互動(介紹mysql各個模組主要職責)

當Connection Manager收到client串連的時候,則會初始化網路連接進程,然後建立Connetion handler進程。進而connection handler進程進行許可權認證。

傳過來的sql指令碼將會被Command Dispatcher接收,如果是個複雜的指令,將會傳到其他的模組去。

在Mysql的術語中,client有兩種請求,一種是query,另外一種是command,query不僅包括select,還包括delete、insert等,這些語句是需要經過parser處理的,而command則不需要經過parser處理。

如果開啟了query logging,那麼command dispatcher 將會讓logging module來做日誌。

command dispatcher在使用parser之前,首先會調用query cache,query cache首先檢查該query是不是可以被cache,是否有符合該query的資料已經被cache,如果有的話,就返回,如果miss了,就會執行parser。

執行好parser之後,select由optimizer來處理;update、 inserts、 deletes和table建立語句,schema建立語句 schema alter語句由table modification module來處理;其他還有table maintenance module,replication module等等。

然後通過維護著table list的access control module,進入到Table manager,開啟表並擷取相應的鎖,然後調用相應的引擎,實現query語句。

abstracted storage engine module自動將query轉化為對應引擎的方法進行處理。

在query語句執行的時候,corresponding module會把一些結果集返回到client。

Mysql沒有使用exceptions,因此在任何一層都需要使用錯誤偵測語句。

當一個任務完成後,就會返回到connection module去等待新的任務。

slave也可能會讀取二進位更新檔案,這將會由master節點來負責。

如果一台機器被定義為slave,那麼將會啟動兩個線程,一個是sql thread,另外一個是i/o線程。

網路連接將會通過Client/server protocol module來實現。而mysql的核心功能都由Core api來實現。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.