Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up PostgreSQL to Citus migration #8134

Merged
Merged
1 change: 0 additions & 1 deletion charts/hedera-mirror/ci/v2-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ graphql:
importer:
env:
SPRING_FLYWAY_PLACEHOLDERS_HASHSHARDCOUNT: "2"
SPRING_FLYWAY_PLACEHOLDERS_IDPARTITIONSIZE: "1000000000000000"
SPRING_FLYWAY_PLACEHOLDERS_PARTITIONTIMEINTERVAL: "'10 years'"
SPRING_FLYWAY_PLACEHOLDERS_SHARDCOUNT: "2"
SPRING_PROFILES_ACTIVE: v2
Expand Down
12 changes: 6 additions & 6 deletions docs/database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ Following are the prerequisites and steps for migrating V1 data to V2.

1. Create a Citus cluster with enough resources (Disk, CPU and memory). For GKE, an e2-custom-6-32768 can be used.
2. Ensure the source and target schemas are compatible by deploying the same version to both.
3. Create a VM with a disk big enough to contain the source data and checkout the source code to it.
4. Populate correct values for the source and target configuration in the
3. Populate correct values for the source and target configuration in the
[migration.config](/hedera-mirror-importer/src/main/resources/db/scripts/v2/migration.config).
5. Get the correct version of [flyway](https://flywaydb.org/documentation/usage/commandline/) based on your OS and
4. Get the correct version of [flyway](https://flywaydb.org/documentation/usage/commandline/) based on your OS and
update it in the `FLYWAY_URL` field in the `migration.config` file. The default is set to the linux version.
6. Stop the [Importer](/docs/importer/README.md) process.
7. Run the [migration.sh](/hedera-mirror-importer/src/main/resources/db/scripts/v2/migration.sh) script.
8. Update the mirror node configuration to point to the new Citus DB and start it.
5. Stop the [Importer](/docs/importer/README.md) process.
6. Run the [migration.sh](/hedera-mirror-importer/src/main/resources/db/scripts/v2/migration.sh) script. Due to the time it will take to complete the migration,
it is recommended to run the script in a way that doesn't require your terminal session to remain open (e.g. `./migration.sh > migration.log 2> migration-error.log & disown`)
7. Update the mirror node configuration to point to the new Citus DB and start it.

## Citus Backup and Restore

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
CONCURRENCY=
EXCLUDED_TABLES=("'entity_state_start'","'flyway_schema_history'","'transaction_hash'")
# Tables to migrate asynchronously. These tables will run last and must contain an indexed consensus_timestamp column
ASYNC_TABLES=("'crypto_transfer'","'transaction'")

# Number of copy jobs to create for each table
ASYNC_TABLE_SPLITS=1000

# Number of tables allowed to be copied concurrently
CONCURRENCY=5

#Number of copy jobs allowed to run concurrently for each table. Only applies to ASYNC_TABLES
CONCURRENT_COPIES_PER_TABLE=5

# Tables to exclude from migration by this script
EXCLUDED_TABLES=("'entity_state_start'","'entity_transaction'","'flyway_schema_history'","'transaction_hash'")

# Download url for flyway
FLYWAY_URL=https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/9.22.3/flyway-commandline-9.22.3-linux-x64.tar.gz

# Maxmium timestamp to copy. If not set, will attempt to load ./migration.env and will fall back to 'select max(consensus_end) from record_file'
MAX_TIMESTAMP=
SOURCE_DB_HOST=
SOURCE_DB_NAME=
Expand Down