Upgrade embedded seekdb
Embedded seekdb cannot be upgraded in place by reusing a data directory created by an earlier version. To upgrade, use seekdb-dump in the old runtime environment to export a logical dump, and then use seekdb-restore in the new runtime environment to restore it into a new, empty instance. This topic uses an upgrade from V1.3.0 to V1.4.0 as the example.
This logical-upgrade procedure does not support data directories created by versions earlier than V1.3.0. A V1.3.0 data directory must be exported by using the seekdb-dump command provided by pylibseekdb 1.3.0.post5. Python embedded users can upgrade the existing Python environment in place to this patch version. seekdb-js (Node.js) and other embedded users must prepare a separate Python environment and install this version. Do not open the old data directory with a V1.4.0 runtime before the export completes.
seekdb-dump and seekdb-restore are distributed with pylibseekdb, but they operate directly on embedded data directories. Therefore, this procedure is not limited to Python applications. It also applies to seekdb-js (Node.js) and other embedded instances that use the same data-directory format. Only the dump and restore tools require a Python environment. After the restore, the new data directory can be used by an embedded client compatible with V1.4.0. If both the old and new instances provide a MySQL-compatible connection endpoint (host and port), you can instead use mysqldump to export SQL from the old instance and import it into the new instance. For instructions, see Upgrade seekdb using mysqldump.
Upgrade workflow
Use the following workflow for a logical upgrade of an embedded instance:
- Stop every embedded application process that accesses the old data directory, and back up the directory.
- Prepare a Python dump environment with
pylibseekdb 1.3.0.post5. Python users can upgrade their existing environment in place. Node.js and other embedded users can create a temporary Python environment. - Run
seekdb-dumpin the dump environment to create MySQL-compatible SQL. - Create a separate V1.4.0 Python restore environment and a new, empty instance directory, and then run
seekdb-restore. - Validate the data and application behavior with an application binding compatible with V1.4.0 before cutting over.
Export the old V1.3.0 data directory only with the pylibseekdb 1.3.0.post5 runtime. Run the restore with the new V1.4.0 runtime and write to a new, empty data directory. Do not open the old data directory directly with the V1.4.0 runtime.
Export scope and limitations
seekdb-dump exports the following user objects:
- Table definitions, indexes, and rows in user databases.
- Views in user databases.
The output is MySQL-compatible SQL text. It does not include:
- System databases.
- Database users or grants.
- Unsupported objects such as triggers, stored procedures, functions, and events.
- Cross-database views that cannot be restored independently, or other views that depend on them.
If unsupported objects are found, seekdb-dump lists them, exits with status 2, and does not create a dump by default. You can specify --ignore-unsupported to export only supported objects, but the dump is marked incomplete and seekdb-restore displays a warning.
Do not use --ignore-unsupported for a logical upgrade unless you explicitly accept the missing objects. Remove, convert, or migrate unsupported objects separately so that you can produce a complete dump.
Before you start
Complete the following preparations:
- Confirm that the old application runtime and old data directory are still usable.
- Prepare a Python dump environment with
pylibseekdb 1.3.0.post5. This can be the existing V1.3.0 Python environment or a temporary environment for a Node.js or other embedded instance. - Create a separate Python environment for the V1.4.0 restore tool. Do not overwrite the dump environment.
- Choose a new data directory for the target instance. Never point the new runtime directly at the old directory.
- Reserve enough storage for a backup of the old directory, the SQL dump, and the new instance.
- Record the old embedded client or binding version, data directory, database list, and application configuration.
- Protect the dump file. It contains application data and must not be readable by unrelated users.
Step 1: Stop the old instance and back it up
Stop every embedded application process that accesses the old data directory, including processes started through Python, Node.js, or another binding. Stopping writes alone is not sufficient. Before exporting, confirm that no other process still has the data directory open. Then back up the directory by using a filesystem snapshot or backup tool.
The directory backup is for rollback only. Do not start the new version directly on that copied directory.
Step 2: Export the old instance
For a Python application, you can install the patch version that provides the export capability in place in the existing V1.3.0 Python environment. For an instance used through seekdb-js (Node.js) or another embedded binding, first create a temporary Python environment. Then run the same installation command:
python -m pip install --upgrade pylibseekdb==1.3.0.post5
Then run the following command in the Python environment that contains pylibseekdb 1.3.0.post5:
seekdb-dump /data/seekdb-v1.3 -o /data/backup/seekdb-v1.3.sql
The first argument is the old instance data directory, and -o specifies the dump file. By default, all user databases are exported.
To export only selected databases, repeat --database:
seekdb-dump /data/seekdb-v1.3 \
--database app_db \
--database archive_db \
-o /data/backup/seekdb-v1.3.sql
After the command completes successfully, the dump ends with the following integrity marker:
-- seekdb-dump-complete: true
If the command reports unsupported objects, resolve them and run the dump again. Do not continue an upgrade with a failed or truncated SQL file.
Step 3: Prepare an empty instance with the new version
Install the embedded seekdb package corresponding to V1.4.0 in a separate Python environment. This environment runs the restore tool and does not need to use the same programming language as the application. For installation instructions, see Embedded mode.
Use a new data directory for the target instance, such as /data/seekdb-v1.4. The target must not contain user tables or views. If seekdb-restore detects user objects, it rejects the restore and exits with status 2. After the restore, Python, seekdb-js (Node.js), or another embedded client compatible with V1.4.0 can use this new data directory.
Step 4: Restore into the new instance
Run the following command in the new Python environment:
seekdb-restore /data/seekdb-v1.4 /data/backup/seekdb-v1.3.sql
seekdb-restore restores databases, tables, indexes, rows, and views in dependency order. For a file generated by seekdb-dump, it also performs these checks:
- Verifies that the dump contains the completion marker and rejects a truncated file.
- Verifies that the target instance is empty.
- Compares each restored table's row count with the count recorded in the dump.
The command returns a nonzero status if a check or SQL statement fails. Do not connect the application to that target directory. Prepare another empty directory, resolve the error, and restore again.
Step 5: Validate and cut over
After the restore completes, perform at least the following checks:
- Confirm that all expected databases, tables, and views are present.
- Check row counts and representative business data in critical tables.
- Validate regular, vector, and full-text indexes and their queries.
- Check critical data types, including
TIMESTAMP, binary values, JSON, and vectors. - Re-create users and grants, which are not included in the dump.
- Start the application with the new data directory and run read/write smoke tests.
Allow production writes only after validation succeeds.
Roll back
Keep the old application runtime, the Python dump environment, the old data directory, and its backup until the upgrade has been accepted. Do not modify or delete them during validation.
If the new instance has not accepted writes, stop it and point the application back to the old directory. If the new instance has accepted writes, simply switching back loses those changes. Stop writes first and perform a reverse logical migration or reconcile the new data before rolling back.
Troubleshooting
The target instance contains user objects
seekdb-restore can restore only into an empty instance. Use a new data directory, or initialize a clean target before restoring again.
The dump reports unsupported objects
Resolve the reported triggers, stored programs, events, or cross-database views and run the dump again. Use --ignore-unsupported only when you explicitly accept the missing objects.
The dump is incomplete or has no completion marker
The file might be truncated or only partially copied. Run seekdb-dump again against the old instance. Do not add the completion marker manually.
Row-count validation fails after restore
Do not use the current target instance. Preserve the error output, prepare another empty directory, and repeat the dump and restore.