Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b1acf21

Browse files
committed
pgbench tables sharded.
I think it is high time to implement sharded tables drop.
1 parent a3bc527 commit b1acf21

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

devops/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ logs/
66
/postgresql.conf.lord
77
/postgresql.conf.worker
88

9-
*.log
9+
# vagrant stuff
10+
*.log
11+
.vagrant/

devops/pgbench_prepare.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
### create pgbench_history everywhere, create pgbench tables on init node,
2+
# shard them. TODO: drop sharded tables.
3+
4+
- hosts: workers
5+
environment:
6+
PATH: "{{ pg_dst }}/bin:{{ ansible_env.PATH }}"
7+
8+
tasks:
9+
- name: recreate pgbench_history on workers
10+
command: >
11+
psql -p {{ pg_port }} -c "drop table if exists pgbench_history;
12+
create table pgbench_history (tid int, bid int, aid int,
13+
delta int, mtime timestamp, filler char(22));"
14+
tags:
15+
- pgbench_history
16+
17+
- hosts: init_node
18+
vars:
19+
scale: 3
20+
nparts: 3
21+
repfactor: 0
22+
environment:
23+
PATH: "{{ pg_dst }}/bin:{{ ansible_env.PATH }}"
24+
25+
tasks:
26+
- name: drop old pgbench tables with deps
27+
command: >
28+
psql -p {{ pg_port }} -c "
29+
drop table if exists pgbench_accounts cascade;
30+
drop table if exists pgbench_tellers cascade;
31+
drop table if exists pgbench_branches cascade;
32+
drop table if exists pgbench_tellers cascade;
33+
drop table if exists pgbench_accounts cascade;
34+
"
35+
tags:
36+
- pgbench_init
37+
38+
- name: learn init node id
39+
command: >
40+
psql -p {{ pg_port }} -qtA -c "select shardman.my_id();"
41+
register: my_id
42+
until: my_id.stdout != ""
43+
retries: 19481948 # oh my
44+
tags:
45+
- pgbench_init
46+
47+
- name: initialize pgbench, scale {{ scale }}
48+
command: >
49+
pgbench -p {{ pg_port }} -s {{ scale }} -i
50+
tags:
51+
- pgbench_init
52+
53+
- name: create_hash_partitions, nparts {{ nparts }}
54+
command: >
55+
psql -p {{ pg_port }} -c "
56+
select shardman.create_hash_partitions({{ my_id.stdout }}, 'pgbench_accounts', 'aid', {{ nparts }});
57+
select shardman.create_hash_partitions({{ my_id.stdout }}, 'pgbench_tellers', 'tid', {{ nparts }});
58+
select shardman.create_hash_partitions({{ my_id.stdout }}, 'pgbench_branches', 'bid', {{ nparts }});
59+
"
60+
tags:
61+
- create_hash_partitions
62+
63+
- name: set_repfactor, repfactor {{ repfactor }}
64+
command: >
65+
psql -p {{ pg_port }} -c "
66+
select shardman.set_replevel('pgbench_accounts', {{ repfactor }});
67+
select shardman.set_replevel('pgbench_tellers', {{ repfactor }});
68+
select shardman.set_replevel('pgbench_branches', {{ repfactor }});
69+
"
70+
tags:
71+
- set_repfactor
72+
when: repfactor != 0

devops/readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ ansible-playbook -i inventory_ec2 pg_ctl.yml -e "pg_ctl_action=restart"
5252
Read cmd log on shardlord:
5353
ansible-playbook -i inventory_ec2/ psql.yml --limit 'shardlord' -e "cmd='\'table shardman.cmd_log\''"
5454
Read nodes table on workers:
55-
nodes': ansible-playbook -i inventory_manual/ psql.yml --limit 'workers' -e "cmd='\'table shardman.nodes\''"
55+
nodes': ansible-playbook -i inventory_ec2/ psql.yml --limit 'workers' -e "cmd='\'table shardman.nodes\''"
56+
57+
Create, fill and shard pgbench tables:
58+
ansible-playbook -i inventory_ec2/ pgbench_prepare.yml -e "scale=10 nparts=10 repfactor=1"
5659

5760
Gather logs to ./logs:
5861
ansible-playbook -i inventory_ec2/ logs.yml

0 commit comments

Comments
 (0)