|
| 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 |
0 commit comments