閱讀735 返回首頁    go 阿裏雲 go 技術社區[雲棲]


PostgreSQL 10.0 preview 功能增強 - 動態視圖pg_stat_activity新增數據庫管理進程信息

標簽

PostgreSQL , 10.0 , pg_stat_activity , 管理進程 , 後台進程 , 工作進程 , 並行計算進程


背景

PostgreSQL為進程模型,啟動時、啟動後會fork一些管理進程,以及用戶連接時會產生用戶的服侍進程。

例如

1. postmaster,負責監聽

2. startup進程,負責recovery

3. logger, 負責寫日誌

4. shared buffer writer,負責通過LRU算法刷髒頁,持久化數據文件

5. wal buffer writer,負責將WAL寫入WAL日誌文件

6. checkpointer,負責檢查點任務

7. stats process,負責收集統計信息,更新計數器計數(query 消耗資源統計、表插入記錄數、更新記錄數、刪除記錄數、deadtuple 等等)。

8. autovacuum launcher,負責監控表的年齡,垃圾比例,觸動閾值時喚醒vacuum worker進行垃圾回收,更新表的統計信息(用於執行計劃成本計算的統計信息,pg_stats)。

9. autovacuum worker,自動垃圾回收的工作進程。

10. 並行計算worker process,當執行並行計算任務時的工作進程。

11. wal sender,作為上遊節點時,流複製消息發送進程。

12. wal receiver,作為下遊節點是,流複製消息接收進程。

13. 其他worker process,其他插件開發的工作進程。

14. user backend process,用戶進程。

以前的版本,數據庫的管理進程都不會被展示出來,10.0擴展了pg_stat_activity視圖的功能,增加了一個進程類型字段,所有進程的信息都會被展示。

方便管理員觀察數據庫的運行狀態。

+    <row>  
+     <entry><structfield>backend_type</structfield></entry>  
+     <entry><type>text</type></entry>  
+     <entry>Type of current backend. Possible types are   
+      <literal>autovacuum launcher</>, <literal>autovacuum worker</>,  
+      <literal>background worker</>, <literal>background writer</>,  
+      <literal>client backend</>, <literal>checkpointer</>,  
+      <literal>startup</>, <literal>walreceiver</>,  
+      <literal>walsender</> and <literal>walwriter</>.  
+     </entry>  
+    </row>  

patch信息如下

Show more processes in pg_stat_activity.  
  
Previously, auxiliary processes and background workers not connected  
to a database (such as the logical replication launcher) weren't  
shown.  Include them, so that we can see the associated wait state  
information.  Add a new column to identify the processes type, so that  
people can filter them out easily using SQL if they wish.  
  
Before this patch was written, there was discussion about whether we  
should expose this information in a separate view, so as to avoid  
contaminating pg_stat_activity with things people might not want to  
see.  But putting everything in pg_stat_activity was a more popular  
choice, so that's what the patch does.  
  
Kuntal Ghosh, reviewed by Amit Langote and Michael Paquier.  Some  
revisions and bug fixes by me.  
  
Discussion: https://postgr.es/m/CA+TgmoYES5nhkEGw9nZXU8_FhA8XEm8NTm3-SO+3ML1B81Hkww@mail.gmail.com         

這個patch的討論,詳見郵件組,本文末尾URL。

PostgreSQL社區的作風非常嚴謹,一個patch可能在郵件組中討論幾個月甚至幾年,根據大家的意見反複的修正,patch合並到master已經非常成熟,所以PostgreSQL的穩定性也是遠近聞名的。

參考

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=fc70a4b0df38bda6a13941f1581f25fbb643c7f3

最後更新:2017-04-01 17:13:51

  上一篇:go 性能測試腳本的編寫和調試【雲享團】
  下一篇:go 我就是來試一試這個東西