Skip to content

Commit e5146e2

Browse files
fix: Bootrapping improved (#49)
* fix: Bootrapping improved * Add indexes creation and fix user creation
1 parent 443f23c commit e5146e2

File tree

6 files changed

+285
-14
lines changed

6 files changed

+285
-14
lines changed

bootstrap/pgbouncer/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ variable "load_balancer" {
2727
}
2828

2929
variable "certs_configmap_name" {
30-
type = string
30+
type = string
3131
default = "pgbouncer-certs"
3232
}
3333

@@ -41,22 +41,22 @@ variable "pg_bouncer_user_settings" {
4141
}
4242

4343
variable "pg_bouncer_auth_user_password" {
44-
type = string
44+
type = string
4545
default = ""
4646
}
4747

4848
variable "postgres_secret_name" {
49-
type = string
49+
type = string
5050
default = ""
5151
}
5252

5353
variable "instance_role" {
54-
type = string
54+
type = string
5555
default = "pgbouncer"
5656
}
5757

5858
variable "postgres_instance_name" {
59-
type = string
59+
type = string
6060
default = "postgres-dbsync-v3-ar9"
6161
}
6262

bootstrap/pgbouncer/pg-bouncer.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ resource "kubernetes_deployment_v1" "pgbouncer" {
1010
}
1111

1212
spec {
13-
replicas = 1
13+
replicas = var.pg_bouncer_replicas
1414

1515
strategy {
1616
rolling_update {

bootstrap/postgres/postgres.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ resource "kubernetes_stateful_set_v1" "postgres" {
8484
}
8585

8686
volume_mount {
87-
mount_path = "/etc/postgresql/postgresql.conf"
87+
mount_path = "/etc/postgresql"
8888
name = "config"
89-
sub_path = "postgresql.conf"
9089
}
9190

9291
volume_mount {

bootstrap/postgres/postgresql.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
listen_addresses = '*'
2-
max_connections = 100
3-
shared_buffers = 12GB
4-
effective_cache_size = 36GB
2+
max_connections = 125
3+
shared_buffers = 15GB
4+
effective_cache_size = 45GB
55
maintenance_work_mem = 2GB
66
checkpoint_completion_target = 0.9
77
wal_buffers = 16MB

bootstrap/postgres/queries.sql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- create pg bouncer role and user_search function - add to each database
22

33
CREATE ROLE pgbouncer WITH PASSWORD 'pgbounceruserpass';
4+
ALTER ROLE pgbouncer WITH LOGIN;
45

56
CREATE OR REPLACE FUNCTION user_search(uname TEXT) RETURNS TABLE (usename name, passwd text) as
67
$$
@@ -724,7 +725,7 @@ CREATE INDEX IF NOT EXISTS idx_tx_metadata_collection_offers ON public.tx_metada
724725

725726

726727

727-
CREATE INDEX stake_address_idx ON stake_address("view");
728+
CREATE INDEX IF NOT EXISTS stake_address_idx ON stake_address("view");
728729

729730

730731
--- BLOCKFROST
@@ -762,7 +763,7 @@ CREATE INDEX IF NOT EXISTS bf_idx_reference_tx_in_tx_in_id ON reference_tx_in (t
762763
CREATE INDEX IF NOT EXISTS bf_idx_collateral_tx_in_tx_in_id ON collateral_tx_in (tx_in_id);
763764

764765

765-
CREATE INDEX CONCURRENTLY IF NOT EXISTS bf_idx_redeemer_script_hash ON redeemer USING HASH (encode(script_hash, 'hex'));
766+
CREATE INDEX IF NOT EXISTS bf_idx_redeemer_script_hash ON redeemer USING HASH (encode(script_hash, 'hex'));
766767

767768

768769
CREATE INDEX IF NOT EXISTS bf_idx_redeemer_tx_id ON redeemer USING btree (tx_id);
@@ -774,4 +775,4 @@ CREATE INDEX IF NOT EXISTS bf_idx_col_tx_out ON collateral_tx_out USING btree (t
774775
CREATE INDEX IF NOT EXISTS bf_idx_ma_tx_mint_ident ON ma_tx_mint USING btree (ident);
775776

776777

777-
CREATE INDEX CONCURRENTLY IF NOT EXISTS bf_idx_ma_tx_out_ident ON ma_tx_out USING btree (ident);
778+
CREATE INDEX IF NOT EXISTS bf_idx_ma_tx_out_ident ON ma_tx_out USING btree (ident);

0 commit comments

Comments
 (0)