summaryrefslogtreecommitdiff
path: root/tools/zk-ca.sh
diff options
context:
space:
mode:
authorJames E. Blair <jim@acmegating.com>2023-02-24 15:19:25 -0800
committerJames E. Blair <jim@acmegating.com>2023-03-29 17:12:13 -0700
commit7153505cd5697610d157c97576ddaa9ba9137613 (patch)
treee8368c1d8f0163c2b1cfc87aad15fba2ad0358cb /tools/zk-ca.sh
parent48ad958bb4e37e165b422daaaefb59d0ab708306 (diff)
downloadzuul-7153505cd5697610d157c97576ddaa9ba9137613.tar.gz
Fix prune-database command
This command had two problems: * It would only delete the first 50 buildsets * Depending on DB configuration, it may not have deleted anything or left orphan data. We did not tell sqlalchemy to cascade delete operations, meaning that when we deleted the buildset, we didn't delete anything else. If the database enforces foreign keys (innodb, psql) then the command would have failed. If it doesn't (myisam) then it would have deleted the buildset rows but not anything else. The tests use myisam, so they ran without error and without deleting the builds. They check that the builds are deleted, but only through the ORM via a joined load with the buildsets, and since the buildsets are gone, the builds weren't returned. To address this shortcoming, the tests now use distinct ORM methods which return objects without any joins. This would have caught the error had it been in place before. Additionally, the delet operation retained the default limit of 50 rows (set in place for the web UI), meaning that when it did run, it would only delete the most recent 50 matching builds. We now explicitly set the limit to a user-configurable batch size (by default, 10,000 builds) so that we keep transaction sizes manageable and avoid monopolizing database locks. We continue deleting buildsets in batches as long as any matching buildsets remain. This should allow users to remove very large amounts of data without affecting ongoing operations too much. Change-Id: I4c678b294eeda25589b75ab1ce7c5d0b93a07df3
Diffstat (limited to 'tools/zk-ca.sh')
0 files changed, 0 insertions, 0 deletions