Skip to content

Commit e37ec91

Browse files
committed
Imporove sleep statistic reporting
2 parents e2050fa + 0510958 commit e37ec91

File tree

11 files changed

+291
-166
lines changed

11 files changed

+291
-166
lines changed

tests/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/deploy/hosts
2+
/deploy/pg_cluster_install.tgz
3+
/perf.results

tests/deploy/cluster.yml

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,68 @@
11
---
22

33
- hosts: nodes
4+
# gather_facts: no
5+
# pre_tasks:
6+
# - name: make a list
7+
# set_fact:
8+
# ansible_os_family: "Debian"
49

510
roles:
6-
711
- role: postgres
812
pg_port: 15432
913
pg_repo: https://github.com/kelvich/postgresql.git
1014
pg_version_tag: xtm_patched
1115
pg_destroy_and_init: true
12-
pg_datadir: ./postgrespro-data
16+
pg_copydist: true
1317
pg_config_role:
1418
- line: "dtm.vacuum_delay=1000"
1519

1620
tasks:
21+
# - name: clone dtm sources
22+
# git: repo=https://github.com/postgrespro/pg_tsdtm.git
23+
# dest={{pg_prefix}}/pg_tsdtm
24+
# accept_hostkey=yes
25+
# update=yes
26+
# force=yes
27+
# register: dtm_sources
1728

18-
- name: clone dtm sources
19-
git: repo=https://github.com/postgrespro/pg_tsdtm.git
20-
dest=./pg_tsdtm
21-
accept_hostkey=yes
22-
update=yes
23-
force=yes
24-
register: dtm_sources
25-
26-
- name: build dtm
27-
shell: "PG_CONFIG={{pg_dst}}/bin/pg_config make clean && PG_CONFIG={{pg_dst}}/bin/pg_config make -j {{makejobs}} install"
28-
args:
29-
chdir: ./pg_tsdtm
30-
when: dtm_sources.changed
29+
# - name: build dtm
30+
# shell: "make clean && make -j {{makejobs}} install"
31+
# args:
32+
# chdir: "{{pg_prefix}}/pg_tsdtm"
33+
# environment:
34+
# PG_CONFIG: "{{pg_dst}}/bin/pg_config"
35+
# when: dtm_sources.changed
3136

3237
- name: enable dtm extension on datanodes
3338
lineinfile:
3439
dest: "{{pg_datadir}}/postgresql.conf"
35-
regexp: "^shared_preload_libraries "
40+
regexp: "^shared_preload_libraries"
3641
line: "shared_preload_libraries = 'pg_dtm'"
3742
state: present
3843

3944
- name: restart postgrespro
40-
command: "{{pg_dst}}/bin/pg_ctl restart -w -D ./postgrespro-data -l ./postgrespro-data/pg.log"
45+
command: "{{pg_dst}}/bin/pg_ctl restart -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
46+
environment:
47+
LD_LIBRARY_PATH: "$LD_LIBRARY_PATH:{{pg_dst}}/lib/"
48+
49+
- hosts: clients
50+
tasks:
51+
- name: increase max open files
52+
lineinfile:
53+
dest: /etc/security/limits.d/cluster.conf
54+
line: "{{item}}"
55+
state: present
56+
create: true
57+
with_items:
58+
- '{{ansible_ssh_user}} soft nofile 65535'
59+
- '{{ansible_ssh_user}} hard nofile 65535'
60+
sudo: yes
61+
62+
- name: copy pg source
63+
copy: src=./{{item}} dest=~/{{item}} mode=0755
64+
with_items:
65+
- "pg_cluster_install.tgz"
66+
67+
- name: extract postgres
68+
command: "tar xzf pg_cluster_install.tgz"

tests/deploy/hosts

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/deploy/hosts.sample

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
[clients]
2-
client1 ansible_ssh_user=cluster offset=6001
2+
158.250.29.4 ansible_ssh_user=cluster offset=1
3+
158.250.29.7 ansible_ssh_user=cluster ansible_ssh_port=2299 offset=100001
34

45
[nodes]
5-
nodes1 ansible_ssh_user=cluster offset=2001
6+
158.250.29.5 ansible_ssh_user=cluster
7+
158.250.29.6 ansible_ssh_user=cluster
8+
158.250.29.8 ansible_ssh_user=cluster
9+
158.250.29.9 ansible_ssh_user=cluster
10+
158.250.29.10 ansible_ssh_user=cluster
611

712
[master]
8-
master1 ansible_ssh_user=cluster offset=1
13+
158.250.29.10 ansible_ssh_user=cluster
14+
15+
[local]
16+
localhost

tests/deploy/roles/postgres/tasks/main.yml

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
- bison
1111
- flex
1212
- libreadline-dev
13-
when: ansible_os_family == "Debian"
13+
when: (pg_copydist is undefined) and ansible_os_family == "Debian"
1414
sudo: yes
1515

1616
- name: ensure dependencies (RedHat)
1717
yum: name="@Development tools" state=present
18-
when: ansible_os_family == "RedHat"
18+
when: (pg_copydist is undefined) and ansible_os_family == "RedHat"
1919
sudo: yes
2020

2121
- name: ensure dependencies (RedHat)
@@ -27,42 +27,83 @@
2727
- bison
2828
- flex
2929
- readline-devel
30-
when: ansible_os_family == "RedHat"
30+
when: (pg_copydist is undefined) and ansible_os_family == "RedHat"
3131
sudo: yes
3232

33+
- name: increase semaphores
34+
shell: sysctl kernel.sem='1000 128000 128 512'
35+
sudo: yes
36+
37+
- name: increase max open files
38+
lineinfile:
39+
dest: /etc/security/limits.d/cluster.conf
40+
line: "{{item}}"
41+
state: present
42+
create: true
43+
with_items:
44+
- '{{ansible_ssh_user}} soft nofile 65535'
45+
- '{{ansible_ssh_user}} hard nofile 65535'
46+
sudo: yes
47+
48+
#############################################################################
49+
3350
- name: clone postgres sources
3451
git: repo={{pg_repo}}
3552
dest={{pg_src}}
3653
version={{pg_version_tag}}
3754
depth=1
3855
accept_hostkey=True
3956
register: pg_sources
40-
41-
#############################################################################
42-
43-
- stat: path={{pg_datadir}}/postmaster.pid
44-
register: pg_pidfile
45-
46-
- name: stop postgres if it was running
47-
command: "{{pg_dst}}/bin/pg_ctl stop -w -D {{pg_datadir}}"
48-
when: pg_pidfile.stat.exists
57+
when: pg_copydist is undefined
4958

5059
- name: force rebuild on changed sources
5160
command: "rm -f {{pg_dst}}/bin/postgres"
52-
when: pg_sources.changed
61+
when: (pg_copydist is undefined) and pg_sources.changed
5362

5463
- name: build and install
5564
shell: ./configure --prefix={{pg_dst}} --without-zlib && make clean && make -j {{makejobs}} && make install
5665
args:
5766
chdir: "{{pg_src}}"
5867
creates: "{{pg_dst}}/bin/postgres"
68+
when: pg_copydist is undefined
69+
70+
#############################################################################
71+
72+
- name: copy pg source
73+
copy: src=./{{item}} dest=~/{{item}} mode=0755
74+
with_items:
75+
- "pg_cluster_install.tgz"
76+
when: pg_copydist is defined
77+
78+
- name: extract postgres
79+
command: "tar xzf pg_cluster_install.tgz"
80+
when: pg_copydist is defined
81+
82+
#############################################################################
83+
84+
- stat: path={{pg_datadir}}/postmaster.pid
85+
register: pg_pidfile
86+
87+
# - name: stop postgres if it was running
88+
# command: "{{pg_dst}}/bin/pg_ctl stop -w -D {{pg_datadir}}"
89+
# environment:
90+
# LD_LIBRARY_PATH: "{{pg_dst}}/lib"
91+
# when: pg_pidfile.stat.exists
92+
93+
- name: stop postgres if it was running
94+
shell: "kill -9 `head -n 1 {{pg_datadir}}/postmaster.pid`"
95+
environment:
96+
LD_LIBRARY_PATH: "$LD_LIBRARY_PATH:{{pg_dst}}/lib"
97+
when: pg_pidfile.stat.exists
5998

6099
- name: remove datadirs on datanodes
61100
command: "rm -rf {{pg_datadir}}"
62101
when: pg_destroy_and_init
63102

64103
- name: create datadirs on datanodes
65104
command: "{{pg_dst}}/bin/initdb {{pg_datadir}}"
105+
environment:
106+
LD_LIBRARY_PATH: "$LD_LIBRARY_PATH:{{pg_dst}}/lib/"
66107
args:
67108
creates: "{{pg_datadir}}"
68109

@@ -85,11 +126,8 @@
85126
dest: "{{pg_datadir}}/pg_hba.conf"
86127
line: "host all all 0.0.0.0/0 trust"
87128

88-
# - include: pg_shard.yml
89-
# when: deploy_pg_shard
90-
91129
- name: start postgrespro
92-
command: "{{pg_dst}}/bin/pg_ctl start -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
93-
94-
130+
shell: "{{pg_dst}}/bin/pg_ctl start -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
131+
environment:
132+
LD_LIBRARY_PATH: "$LD_LIBRARY_PATH:{{pg_dst}}/lib"
95133

tests/deploy/roles/postgres/vars/main.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,12 @@
22
---
33
makejobs: 4
44

5-
deploy_postgres: false
6-
deploy_dtm: false
7-
deploy_pg_shard: false
8-
95
pg_repo: git://git.postgresql.org/git/postgresql.git
106
pg_version_tag: master
117

12-
138
pg_destroy_and_init: false
149

15-
1610
pg_port: 5432
17-
pg_dtm_enable: false
18-
pg_dtm_host: "127.0.0.1"
1911
pg_config:
2012
- line: "shared_buffers = 3GB"
2113
- line: "wal_keep_segments = 128"
@@ -27,18 +19,8 @@ pg_config:
2719
- line: "port = {{pg_port}}"
2820
pg_config_role:
2921
- line: "#pg_config_role"
30-
pg_src: ~/postgrespro
31-
pg_dst: /tmp/postgrespro-build
32-
pg_datadir: ~/postgrespro-data
33-
34-
libuv:
35-
version: v1.7.5
36-
src: ./libuv
37-
dst: /tmp/libuv-build
38-
39-
dtmd:
40-
port: 5431
41-
dst: ./dtmd
42-
datadir: ./dtmd-data
43-
log: ./dtmd.log
4422

23+
pg_prefix: "{{ansible_env.HOME}}/pg_cluster"
24+
pg_src: "{{pg_prefix}}/src"
25+
pg_dst: "{{pg_prefix}}/install"
26+
pg_datadir: "{{pg_prefix}}/data_{{pg_port}}"

0 commit comments

Comments
 (0)