Postgres migrationClickHouse Workshops

07 Validate your knowledge and tear down

Check your understanding with fourteen questions, then delete the workshop resources.

Your computer
macOS terminal: Run workshop commands in Terminal using zsh or bash.

No infrastructure changes until the teardown at the end. Budget 20 to 30 minutes for the questions and 15 for the teardown.

Outcome

A score you can act on, and an AWS account and ClickHouse organization with nothing left running.

What this is testing

Answer fourteen questions about replication, cutover, routing, and measurement.

The coverage maps onto the modules:

  • Which replication tool does which hop, and what happens when you reach for the wrong one;
  • What logical replication does not carry, and what the first write after cutover does about it;
  • What makes a cutover window short, and which step dominates it;
  • What an orphaned replication slot costs, on which machine, and how the symptom misdirects;
  • Why ReplacingMergeTree, and what the ordering key has to contain for it to be correct;
  • What search_path shadowing changes and what it leaves alone, including which sessions see it and when;
  • How to read an EXPLAIN for pushdown, and what a plan with an aggregate above a Foreign Scan is telling you; and
  • What the benchmark proves and what it does not — including the PostgresBench citation, which substantiates exactly one sentence.

Sign in with a verified work email to take the assessment. Answer every question, then submit to view your score and explanations. Each attempt is recorded, and you can retry after reviewing the relevant modules.

Loading assessment...

Review the relevant module if you need more context for an answer.

Teardown

Delete the workshop resources even if you stop before completing the assessment. They continue to incur charges while running.

Delete each pipe while its source is reachable so it can remove its replication slot:

  • The migration pipe holds a replication slot on RDS. Delete the pipe before destroying RDS and verify slot removal.
  • The ClickPipe reads from Managed Postgres and holds a replication slot there. Delete the pipe before the instance.

1. Stop the local processes

kill "$(cat /tmp/writer.pid)" 2>/dev/null && sleep 3 && tail -1 /tmp/writer.log
cd "$(git rev-parse --show-toplevel)/workshops/postgres_migration/grafana"
docker compose down

2. Delete the migration pipe, while RDS is still up

If you already deleted it at the end of module 04, confirm and move on. Order matters here: deleting the pipe while RDS is still reachable is what lets it remove the replication slot it created. Destroy RDS first and the pipe has nothing to clean up on a machine that no longer exists.

Delete the pipe from Data sources on your Managed Postgres service, then check the source:

psql -h "$RDS_HOST" -c "SELECT slot_name, active FROM pg_replication_slots;"
psql -h "$RDS_HOST" -c "SELECT pubname FROM pg_publication;"

The first query must return no rows. The second normally still lists the pipe's generated publication, which is harmless — publications retain no WAL — and goes with the instance in the next step anyway. If the slot query returns a row, drop it explicitly: an inactive slot on a live instance is the disk-fill timer from module 03's failure injection, still running.

psql -h "$RDS_HOST" -c "SELECT pg_drop_replication_slot('<slot_name>');"

3. Delete the ClickPipe

In the ClickHouse Cloud console, open the ClickPipe you created in module 05 and delete it. Then confirm its slot is gone from Managed Postgres:

psql "$TARGET_DSN" -c "SELECT slot_name, active FROM pg_replication_slots;"

The slot query must return no rows. Remove any remaining inactive workshop slot before deleting Managed Postgres.

4. Destroy the RDS instance and everything around it

The two aws checks below run after the destroy, when terraform output has nothing left to read, so re-export the region first.

cd "$(git rev-parse --show-toplevel)/workshops/postgres_migration/terraform"
export AWS_REGION="$(terraform output -raw region)"
echo "$AWS_REGION"
terraform destroy

This removes the DB instance, the custom parameter group, the DB subnet group and the security group — including the wide port 5432 allowlist you opened in module 03, which is the revert that matters most here. skip_final_snapshot is set, so nothing lingers as a snapshot you keep paying for.

Verify with Terraform and then independently, because a destroy that failed partway is the expensive case:

terraform state list
aws rds describe-db-instances --query "DBInstances[].DBInstanceIdentifier" --output table
aws rds describe-db-snapshots --snapshot-type manual --query "DBSnapshots[].DBSnapshotIdentifier" --output table

terraform state list prints nothing. Neither AWS query should name anything belonging to this workshop.

5. Delete the Managed Postgres instance

Delete it with the same CLI that created it in module 03. Its shop database, the two roles, the foreign server and the ch schema all go with it; there is nothing to clean up inside it first.

clickhousectl cloud postgres delete "$TARGET_PG_ID"

If TARGET_PG_ID is not set — a fresh terminal, or you are back the next day — list the instances and take the id from there. Do this rather than skipping the step: a Managed Postgres instance left running is the second most expensive thing this workshop can leave behind, after the RDS instance you just destroyed.

clickhousectl cloud postgres list

list is beta and may return empty or FORBIDDEN depending on your API key's role. If it does, use the console — Managed Postgres — and do not take an empty list as proof that nothing is running.

6. Delete the ClickHouse service

Delete the service created in module 05, including its shop database and the workshop user:

clickhousectl cloud service delete "$CH_SERVICE_ID"

If CH_SERVICE_ID is not set — a fresh terminal, or a later day — list them and take the id from there:

clickhousectl cloud service list

Check the name against the id before you confirm, especially if your organization has other services. This is the one deletion in the teardown that can hit something that is not yours.

7. Keep what is worth keeping

Keep the benchmark results and completed runbook:

cd "$(git rev-parse --show-toplevel)/workshops/postgres_migration"
ls bench/results/
cat runbook/cutover.md
rm -f .env.local /tmp/schema.sql /tmp/source.txt /tmp/target.txt

bench/results/before.json and after.json hold both measurements with their configuration blocks. runbook/cutover.md is the document you wrote, executed and amended — it is the thing to take to work. Delete .env.local; it holds the two role passwords.

Nothing left running

ResourceWhereGone when
RDS instance, parameter group, subnet group, security groupAWSterraform state list is empty
Manual DB snapshotsAWSdescribe-db-snapshots --snapshot-type manual names none
ClickPipeClickHouse Clouddeleted, and no slot remains on Managed Postgres
Managed Postgres instanceClickHouse Clouddeleted
ClickHouse serviceClickHouse Clouddeleted
Grafana containeryour machinedocker compose down
Order writeryour machinethe process is gone

Completion checks

  • Every row of the table above is confirmed, not assumed;
  • terraform state list prints nothing and no AWS query names a workshop resource;
  • Both replication slots are gone, on both instances, before the instances were;
  • bench/results/ holds both runs; and
  • .env.local is deleted.

What you did

You migrated the transactional workload to Managed Postgres, reset sequences, and verified replication-slot cleanup. You then copied the data into ClickHouse and routed analytical queries through pg_clickhouse. Keep your runbook, measured downtime, query plans, and benchmark configuration for future migrations.

本页内容

Track your progress?

Optional. We email a link to confirm your address; progress records once you open it.

Please use your work email address, not a personal one.

By continuing you accept the Terms.

ZH