Skip to content

Commit

Permalink
Autovacuum crypto_transfer, token_transfer, and transaction (#1825)
Browse files Browse the repository at this point in the history
- configure more frequent anti-wraparound autovacuum for crypto_transfer, token_transfer, and transaction for pg 9.6
- configure more frequent insert-only autovacuum for crypto_transfer, token_transfer, and transaction for pg 13
- upgrade to timescale/timescaledb-ha:pg13-ts2.2-latest
- increase shm size for timescaledb container

Signed-off-by: Xin Li <xin.li@hedera.com>
  • Loading branch information
xin-hedera authored Apr 19, 2021
1 parent 0377e63 commit d0addee
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 9 deletions.
6 changes: 3 additions & 3 deletions charts/hedera-mirror/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
version: 0.18.0-rc1
- name: postgresql-ha
repository: https://charts.bitnami.com/bitnami
version: 6.8.2
version: 6.8.4
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 12.10.1
Expand All @@ -20,5 +20,5 @@ dependencies:
- name: timescaledb-single
repository: https://raw.githubusercontent.com/timescale/timescaledb-kubernetes/master/charts/repo/
version: 0.8.2
digest: sha256:a11e7b528a970d45ee990e77b8348b92798cbc3f2bdf3d499d3fabe338d20932
generated: "2021-04-06T09:28:14.383611-05:00"
digest: sha256:0961730bd887af0ac2cb9b8b75cab35a6db74939639ce32d0bd44d53cfc6c700
generated: "2021-04-14T15:10:50.836474-05:00"
2 changes: 1 addition & 1 deletion charts/hedera-mirror/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies:
condition: postgresql.enabled
name: postgresql-ha
repository: https://charts.bitnami.com/bitnami
version: ~6.8.1
version: ~6.8.4
- alias: redis
condition: redis.enabled
name: redis
Expand Down
4 changes: 3 additions & 1 deletion charts/hedera-mirror/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ timescaledb:
image:
pullPolicy: IfNotPresent
repository: timescale/timescaledb-ha
tag: pg12.6-ts2.1.1-latest
tag: pg13-ts2.2-latest
loadBalancer:
enabled: false
patroni:
Expand Down Expand Up @@ -222,3 +222,5 @@ timescaledb:
requests:
cpu: 1
memory: 1Gi
sharedMemory:
useMount: true
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ services:
timescaledb:
deploy:
replicas: 0
image: timescale/timescaledb-ha:pg12.6-ts2.1.1-latest
image: timescale/timescaledb-ha:pg13-ts2.2-latest
restart: unless-stopped
stop_grace_period: 2m
stop_signal: SIGTERM
Expand Down
4 changes: 4 additions & 0 deletions hedera-mirror-grpc/src/test/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ spring:
placeholders:
api-password: mirror_api_pass
api-user: mirror_api
autovacuumFreezeMaxAgeInsertOnly: 100000
autovacuumVacuumInsertThresholdCryptoTransfer: 18000000
autovacuumVacuumInsertThresholdTokenTransfer: 2000
autovacuumVacuumInsertThresholdTransaction: 6000000
chunkIdInterval: 10000
chunkTimeInterval: 604800000000000
compressionAge: 9223372036854775807 # use long max to avoid compression during test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
embedded:
postgresql:
docker-image: timescale/timescaledb-ha:pg12.6-ts2.1.1-latest
docker-image: timescale/timescaledb-ha:pg13-ts2.2-latest
spring:
flyway:
baselineVersion: 1.999.999
Expand Down
4 changes: 4 additions & 0 deletions hedera-mirror-importer/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ spring:
placeholders:
api-password: ${hedera.mirror.importer.db.restPassword}
api-user: ${hedera.mirror.importer.db.restUsername}
autovacuumFreezeMaxAgeInsertOnly: 100000
autovacuumVacuumInsertThresholdCryptoTransfer: 18000000
autovacuumVacuumInsertThresholdTokenTransfer: 2000
autovacuumVacuumInsertThresholdTransaction: 6000000
chunkIdInterval: 10000
chunkTimeInterval: 604800000000000
compressionAge: 604800000000000
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-------------------
-- autovacuum insert-only tables more frequently to ensure most pages are visible for index-only scans
-- prior to postgresql 13, this can be achieved by configuring a more aggressive anti-wraparound autovacuum
-------------------

alter table if exists crypto_transfer set (
autovacuum_freeze_max_age = ${autovacuumFreezeMaxAgeInsertOnly},
autovacuum_freeze_table_age = ${autovacuumFreezeMaxAgeInsertOnly},
autovacuum_freeze_min_age = 0,
log_autovacuum_min_duration = 0
);

alter table if exists token_transfer set (
autovacuum_freeze_max_age = ${autovacuumFreezeMaxAgeInsertOnly},
autovacuum_freeze_table_age = ${autovacuumFreezeMaxAgeInsertOnly},
autovacuum_freeze_min_age = 0,
log_autovacuum_min_duration = 0
);

alter table if exists transaction set (
autovacuum_freeze_max_age = ${autovacuumFreezeMaxAgeInsertOnly},
autovacuum_freeze_table_age = ${autovacuumFreezeMaxAgeInsertOnly},
autovacuum_freeze_min_age = 0,
log_autovacuum_min_duration = 0
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-------------------
-- autovacuum insert-only tables more frequently to ensure most pages are visible for index-only scans
-------------------

alter table if exists crypto_transfer set (
autovacuum_vacuum_insert_scale_factor = 0,
autovacuum_vacuum_insert_threshold = ${autovacuumVacuumInsertThresholdCryptoTransfer},
log_autovacuum_min_duration = 0
);

alter table if exists token_transfer set (
autovacuum_vacuum_insert_scale_factor = 0,
autovacuum_vacuum_insert_threshold = ${autovacuumVacuumInsertThresholdTokenTransfer},
log_autovacuum_min_duration = 0
);

alter table if exists transaction set (
autovacuum_vacuum_insert_scale_factor = 0,
autovacuum_vacuum_insert_threshold = ${autovacuumVacuumInsertThresholdTransaction},
log_autovacuum_min_duration = 0
);
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
embedded:
postgresql:
docker-image: timescale/timescaledb-ha:pg12.6-ts2.1.1-latest
docker-image: timescale/timescaledb-ha:pg13-ts2.2-latest
6 changes: 5 additions & 1 deletion hedera-mirror-rest/__tests__/integrationDbOps.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const v1SchemaConfigs = {
const v2SchemaConfigs = {
docker: {
imageName: 'timescale/timescaledb-ha',
tagName: 'pg12.6-ts2.1.1-latest',
tagName: 'pg13-ts2.2-latest',
},
flyway: {
baselineVersion: '1.999.999',
Expand Down Expand Up @@ -125,6 +125,10 @@ const flywayMigrate = () => {
"password": "${dbAdminPassword}",
"placeholders.api-password": "${dbConfig.password}",
"placeholders.api-user": "${dbConfig.username}",
"placeholders.autovacuumFreezeMaxAgeInsertOnly": 100000,
"placeholders.autovacuumVacuumInsertThresholdCryptoTransfer": 18000000,
"placeholders.autovacuumVacuumInsertThresholdTokenTransfer": 2000,
"placeholders.autovacuumVacuumInsertThresholdTransaction": 6000000,
"placeholders.chunkIdInterval": 10000,
"placeholders.chunkTimeInterval": 604800000000000,
"placeholders.compressionAge": 9007199254740991,
Expand Down

0 comments on commit d0addee

Please sign in to comment.