Area: Deployment
Sub-Area: Upgrades
Applies to: OSS
Issue
You run DataHub yourself (Helm on Kubernetes, or the Docker quickstart) and want to move to a newer version without losing metadata. You also want a plan for what to do if the upgrade fails.
If you use DataHub Cloud, this article does not apply to you. DataHub runs the upgrades for Cloud instances. Contact DataHub Support with questions about your Cloud version or an upcoming upgrade.
You Might Be Asking
- How do I upgrade a self-hosted DataHub safely?
- Do I need to run database migrations myself?
- Will I lose metadata during the upgrade?
- How do I roll back if the upgrade fails?
Solution
The full procedure is in Upgrading DataHub. The steps below follow it.
1. Take a backup
DataHub keeps metadata in two places, and each needs its own backup. Versioned aspects live in the metadata_aspect_v2 table of your MySQL or PostgreSQL database. Time series aspects, search indices and graph relationships live in Elasticsearch or OpenSearch. See Backup & Restore.
Dump the versioned metadata table (MySQL example), or take an RDS snapshot if you use AWS RDS:
mysqldump -u <username> -p datahub metadata_aspect_v2 > metadata_aspect_v2_backup.sql
Snapshot the search indices. A self-hosted Elasticsearch cluster needs path.repo: ["/mnt/es-backups"] in elasticsearch.yml on every node first. Then register a snapshot repository and take a snapshot:
curl -X PUT "http://<es-host>:9200/_snapshot/datahub_fs_backup" \
-H "Content-Type: application/json" \
-d '{"type": "fs", "settings": {"location": "/mnt/es-backups", "compress": true}}'
curl -X PUT "http://<es-host>:9200/_snapshot/datahub_fs_backup/snapshot_YYYY_MM_DD?wait_for_completion=true"
Registering the repository does not take a snapshot by itself. You need the second call. For AWS OpenSearch Service, register an s3 repository instead, as shown in Backup & Restore.
For a local Docker quickstart instance, datahub docker quickstart --backup is enough.
An upgrade can migrate or reindex data. Some of those steps are not reversible, and DataHub has no automated rollback. Your backup is what makes a failed upgrade recoverable.
2. Read the breaking changes for every version you pass through
Read Breaking Changes by Version for each version between your current one and your target, not only the target. Going from 1.5.0 to 1.8.0 means reading 1.6.0, 1.7.0 and 1.8.0. Each entry says whether you need to take action. Each release also has a Potential Downtime section that describes reindexing or migrations that run on startup. Plan your maintenance window around the largest one.
Test the upgrade on a non-production copy first.
3. Run the upgrade (Kubernetes)
Bump the chart version, global.datahub.version, or both, then upgrade:
helm repo update datahub
helm search repo datahub/datahub --versions
helm upgrade --install datahub datahub/datahub --values values.yaml
The Helm chart version and the DataHub version are numbered separately. If you pass --version, give it a chart version from helm search repo, not a DataHub release number.
You don't run database migrations by hand. helm upgrade runs the blocking system-update Job as a pre-upgrade hook, rolls out the components, and then runs the non-blocking system-update Job as a post-upgrade hook. The Job applies schema changes and reindexes when needed. See System update and upgrades.
Watch the Job and the pods:
kubectl get jobs
kubectl logs job/<system-update job name>
kubectl get pods
With the release name datahub, the deployments are named datahub-datahub-gms, datahub-datahub-frontend, and so on.
If your pipeline renders the chart with helm template and applies the YAML with Spinnaker, Kustomize or kubectl, the Helm hooks do not run. Follow Upgrading with rendered manifests instead.
For a Docker quickstart instance, run datahub docker quickstart. It pulls the newest images and recreates the containers. If your instance was set up with a CLI older than 1.2, the compose file changed and you need the extra steps in Managing Your Local Instance.
4. Check the upgrade
-
Check that GMS is ready.
/healthreturns HTTP 200 when GMS is ready and HTTP 503 while it is still starting. The response body is empty.curl -i http://<gms-host>:8080/health -
Check API access with a token:
curl -X POST http://<gms-host>:8080/api/graphql \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"query": "{ me { corpUser { username } } }"}' -
Search for a known entity in the UI and open its lineage. If results are missing or stale, let the system-update Job finish before you act. If search or graph data is still wrong after it finishes, rebuild the indices from the database with Restore Indices.
-
Run an ingestion job and confirm it completes.
datahub check pluginslists the source and sink plugins your CLI has installed.datahub ingest -c recipe.yml --dry-runruns the source without writing to the sink.
5. If the upgrade fails
There is no automated rollback. Redeploy the previous version. With Helm, find the last good revision and roll back to it:
helm history datahub
helm rollback datahub <revision>
helm rollback only changes the deployed version. It does not undo data changes. If the upgrade already migrated or reindexed data, restore the database from the backup you took in step 1 (or restore your RDS snapshot):
mysql -u <username> -p datahub < metadata_aspect_v2_backup.sql
After you restore the database, rebuild the search and graph indices from it with Restore Indices. With the Helm chart and the release name datahub, start the job from its template:
kubectl create job --from=cronjob/datahub-datahub-restore-indices-job-template datahub-restore-indices-adhoc
By default this job does not remove documents that are no longer in the database. To clear the indices first, add the -a clean argument as described in Restore Indices.
You can restore your Elasticsearch snapshot instead of rebuilding. In that case, name DataHub's indices in the restore request. The datastream*,metadataindex* pattern in the Backup & Restore example does not match any DataHub index. A snapshot restore matches physical index names, not aliases. After a reindex, the system-update Job creates a new physical index with a timestamp at the end of the name, for example datasetindex_v2_1704067200000. The Job deletes the old index. The plain name, for example datasetindex_v2, then becomes an alias for the new index. GET _cat/indices lists the physical names. Entity search index names contain index_v2, and time series index names contain aspect_v1. The graph and system metadata index names contain graph_service_v1 and system_metadata_service_v1. Your deployment can add a prefix to each name. Use the physical names from GET _cat/indices, or use patterns with a trailing wildcard as in the example below. A pattern that ends at the version, such as *index_v2, does not match a reindexed index. Elasticsearch does not restore over an open index that already exists, so close or delete those indices before you restore. Then run:
curl -X POST "http://<es-host>:9200/_snapshot/datahub_fs_backup/snapshot_YYYY_MM_DD/_restore" \
-H "Content-Type: application/json" \
-d '{"indices": "*index_v2*,*aspect_v1*,*graph_service_v1*,*system_metadata_service_v1*", "include_global_state": false}'
If other applications share the cluster, check that these patterns match only DataHub's indices in your _cat/indices output.
Additional Notes
Back up before every upgrade, and test the restore. Keep your Helm values and custom configuration in version control so you can redeploy the previous version exactly.