feat: Add option to dump and load database snapshots, while keeping relationships on foreign tables.#1873
Conversation
3278ffd to
57707a2
Compare
MarceloRobert
left a comment
There was a problem hiding this comment.
looks ok, I'll test later
2cbd0d8 to
e765709
Compare
e765709 to
be9e90c
Compare
MarceloRobert
left a comment
There was a problem hiding this comment.
it worked for a small interval, but for an interval of 1 day I got an error of
Processed 1610 tests records: 1.53 MiB
Error updating database: read
CommandError: Command failed
I assume it's because it went over the size limit of 32MiB?
Also left some other comments
be9e90c to
dd1cfa2
Compare
|
I think we could remove https://github.com/kernelci/dashboard/blob/main/backend/scripts/copy_db_data.sh as it no longer makes sense after the changes on the command |
| try: | ||
| match table: | ||
| case None: | ||
| self.restore_incidents() |
There was a problem hiding this comment.
Wouldn't be better to restore incidents last here? restore_incidents calls insert_incidents_data that checks for existing issues, builds and tests and could skip incidents incorrectly
There was a problem hiding this comment.
Good catch. Done.
I have managed to find the problem, when spilling the 32MiB, the temporary file is moved to disk, and this was causing the later reads to fail. |
44c6032 to
b575a66
Compare
MarceloRobert
left a comment
There was a problem hiding this comment.
Seems to be all working, just left some nits
a48c6a7 to
e36569b
Compare
relationships on foreign tables.
* Replace direct DB-to-DB migration with snapshot (dump to tar.gz) and restore
(load from archive) subcommands, using CSV serialization and SpooledTemporaryFile
for memory-efficient streaming.
e36569b to
8cd6a92
Compare
MarceloRobert
left a comment
There was a problem hiding this comment.
Tested again and is working well
Include a command to dump and load database snapshots.
Summary
snapshotandrestoresubcommands toupdate_dbmanagement command, replacing the previous direct DB-to-DB migration flow.tar.gzarchives containing per-table CSV files, preserving foreign key relationships on restoreHow to Test
Important
For these tests, especially for writing, use a local database, instead of pointing to production.
poetry run python3 manage.py seed_test_data --clear --yes, or use an existing database.poetry run python3 manage.py update_db snapshot --start-interval "100 days" --end-interval "0 minute" --filepath ./my-snapshot.tar.gzmy-snapshot.tar.gz.run python3 manage.py seed_test_data --clear --yes --checkouts 0 --issues 0poetry run python3 manage.py restore snapshot --start-interval "100 days" --end-interval "0 minute" --filepath ./my-snapshot.tar.gzCloses #1884