Skip to content

Commit fdc1c49

Browse files
committed
repro memory leak under pg_stat_monitor
To do this execute in one terminal: ```bash xpg -v 15 psql ``` And this in another: ```bash watch -n 1 'ps -p $(cat build-15/bgworker.pid) -o %mem,rss,vsz,comm' %MEM RSS VSZ COMMAND 0.1 19164 722508 postgres ``` The RSS should be seen as always growing, which proves the memory leak.
1 parent a4bd576 commit fdc1c49

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

nix/pg_stat_monitor.nix

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{ lib, stdenv, fetchFromGitHub, postgresql }:
2+
3+
stdenv.mkDerivation rec {
4+
pname = "pg_stat_monitor";
5+
version = "2.1.1";
6+
7+
buildInputs = [ postgresql ];
8+
9+
src = fetchFromGitHub {
10+
owner = "percona";
11+
repo = pname;
12+
rev = "refs/tags/${version}";
13+
hash = "sha256-c50l6XpkF5lp8TQd9TFqnms3nc8KAAa+dV/wVjw3Zao=";
14+
};
15+
16+
makeFlags = [ "USE_PGXS=1" ];
17+
18+
installPhase = ''
19+
install -D -t $out *${postgresql.dlSuffix}
20+
install -D -t $out *.sql
21+
install -D -t $out *.control
22+
'';
23+
24+
meta = with lib; {
25+
description = "Query Performance Monitoring Tool for PostgreSQL";
26+
homepage = "https://github.com/percona/${pname}";
27+
maintainers = with maintainers; [ samrose ];
28+
platforms = postgresql.meta.platforms;
29+
license = licenses.postgresql;
30+
broken = lib.versionOlder postgresql.version "15";
31+
};
32+
}

nix/xpg.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ let
33
dep = fetchFromGitHub {
44
owner = "steve-chavez";
55
repo = "xpg";
6-
rev = "v1.3.0";
7-
sha256 = "sha256-jDELiBbnCpRXIpod7msnhMfGcrW0pR3snDQ5T81nO0I=";
6+
rev = "v1.3.1";
7+
sha256 = "sha256-JuTjM/94TAcjYLxZJa/GDfZG/7FvkfG5FKpCTkuZ48k=";
88
};
99
xpg = import dep;
1010
in

shell.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@ mkShell {
99
nginxCustom = callPackage ./nix/nginxCustom.nix {};
1010
nixopsScripts = callPackage ./nix/nixopsScripts.nix {};
1111
xpg = callPackage ./nix/xpg.nix {inherit fetchFromGitHub;};
12+
pg_stat_monitor15 = callPackage ./nix/pg_stat_monitor.nix {
13+
postgresql = xpg.postgresql_15;
14+
};
1215
pythonDeps = with python3Packages; [
1316
pytest
1417
psycopg2
1518
sqlalchemy
1619
];
1720
in
1821
[
19-
xpg.xpg
22+
(xpg.xpgWithExtensions {
23+
exts15 = [ pg_stat_monitor15 ];
24+
})
2025
pythonDeps
2126
nginxCustom.nginxScript
2227
curl

test/init.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
shared_preload_libraries='pg_net'
1+
shared_preload_libraries='pg_net, pg_stat_monitor'
22
log_min_messages=INFO

0 commit comments

Comments
 (0)