日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

Resource Manager

本文介紹了PolarDB PostgreSQL版的Resource Manager功能。

前提條件

支持的PolarDB PostgreSQL版的版本如下:

  • PostgreSQL 14(內核小版本14.5.1.0及以上)

  • PostgreSQL 11(內核小版本1.1.1及以上)

說明

您可通過如下語句查看PolarDB PostgreSQL版的內核小版本的版本號:

  • PostgreSQL 14

    select version();
  • PostgreSQL 11

    show polar_version;

背景信息

PolarDB PostgreSQL版的內存可以分為以下三部分:

  • 共享內存

  • 進程間動態共享內存

  • 進程私有內存

進程間動態共享內存和進程私有內存是動態分配的,其使用量隨著集群承載的業務運行情況而不斷變化。過多使用動態內存,可能會導致內存使用量超過操作系統限制,觸發內核內存限制機制,造成集群進程異常退出,集群重啟,引發集群不可用的問題。

進程私有內存MemoryContext管理的內存可以分為以下兩部分:

  • 工作計算區域內存:業務運行所需的內存,此部分內存會影響業務的正常運行。

  • Cache內存:數據庫會將部分內部元數據存放在進程內,此部分內存只會影響數據庫性能。

為了解決以上問題,PolarDB PostgreSQL版增加了Resource Manager資源限制機制,能夠在集群運行期間,周期性的檢測資源使用情況。對于超過資源限制閾值的進程,強制進行資源限制,降低集群不可用的風險。

Resource Manager主要的限制資源有:內存、CPU、I/O。當前僅支持對內存資源進行限制。

原理介紹

內存限制依賴Cgroup,如果不存在Cgroup,則無法有效進行資源限制。Resource Manager作為PolarDB PostgreSQL版的一個后臺輔助進程,會周期性讀取Cgroup的內存使用數據作為內存限制的依據。當發現存在進程超過內存限制閾值后,Resource Manager會讀取內核的用戶進程內存記賬,按照內存大小排序,依次對內存使用量超過閾值的進程發送中斷進程信號(SIGTERM)或取消操作信號(SIGINT)。

內存限制方式

Resource Manager守護進程會隨著集群啟動而建立,同時對RW、RO以及Standby節點起作用。可以通過修改以下參數改變Resource Manager的行為。

當前Resource Manager限制內存的方式為:在集群內存使用超過Resource Manager參數設定的內存水位線后,會對使用內存較多的進程發送SIGTERM信號,終止進程以釋放內存。具體參數說明如下:

參數

說明

enable_resource_manager

是否啟動Resource Manager。默認值為on,取值如下:

  • on:啟動Resource Manager。

  • off:不啟動Resource Manager。

stat_interval

資源使用量周期檢測的間隔。單位為毫秒,取值范圍為10~10000,默認值為500。

total_mem_limit_rate

限制集群內存使用的百分比,當集群內存使用超過該百分比后,開始強制對內存資源進行限制,默認值為95。

total_mem_limit_remain_size

集群內存預留值,當集群空閑內存小于預留值后,開始強制對內存資源進行限制,單位為KB,取值范圍為131072~MAX_KILOBYTES(整型數值最大值),默認值為524288。

mem_release_policy

內存資源限制的策略。取值如下:

  • none:無動作。

  • default:默認策略(默認值),優先中斷空閑進程,然后中斷活躍進程。

  • cancel_query:中斷活躍進程。

  • terminate_idle_backend:中斷空閑進程。

  • terminate_any_backend:中斷所有進程。

  • terminate_random_backend:中斷隨機進程。

示例

當用戶會話進程接收到SIGTERM信號后,會終止當前進程,并將終止信息寫入到日志中。日志內容如下:

2022-11-28 14:07:56.929 UTC [18179] LOG:  [polar_resource_manager] terminate process 13461 release memory 65434123 bytes
2022-11-28 14:08:17.143 UTC [35472] FATAL:  terminating connection due to out of memory
2022-11-28 14:08:17.143 UTC [35472] BACKTRACE:
        postgres: primary: postgres postgres [local] idle(ProcessInterrupts+0x34c) [0xae5fda]
        postgres: primary: postgres postgres [local] idle(ProcessClientReadInterrupt+0x3a) [0xae1ad6]
        postgres: primary: postgres postgres [local] idle(secure_read+0x209) [0x8c9070]
        postgres: primary: postgres postgres [local] idle() [0x8d4565]
        postgres: primary: postgres postgres [local] idle(pq_getbyte+0x30) [0x8d4613]
        postgres: primary: postgres postgres [local] idle() [0xae1861]
        postgres: primary: postgres postgres [local] idle() [0xae1a83]
        postgres: primary: postgres postgres [local] idle(PostgresMain+0x8df) [0xae7949]
        postgres: primary: postgres postgres [local] idle() [0x9f4c4c]
        postgres: primary: postgres postgres [local] idle() [0x9f440c]
        postgres: primary: postgres postgres [local] idle() [0x9ef963]
        postgres: primary: postgres postgres [local] idle(PostmasterMain+0x1321) [0x9ef18a]
        postgres: primary: postgres postgres [local] idle() [0x8dc1f6]
        /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f888afff445]
        postgres: primary: postgres postgres [local] idle() [0x49d209]