zuul/zuul/cmd
James E. Blair 7153505cd5 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
2023-03-29 17:12:13 -07:00
..
__init__.py Use importlib for versioning 2023-01-23 10:51:08 -08:00
client.py Fix prune-database command 2023-03-29 17:12:13 -07:00
executor.py Unify service stop sequence 2022-05-28 10:27:50 -07:00
fingergw.py Unify service stop sequence 2022-05-28 10:27:50 -07:00
manage_ansible.py Remove ununecessary shebangs 2020-05-18 19:10:33 +02:00
merger.py Correct exit routine in web, merger 2022-10-05 13:25:07 -07:00
scheduler.py Correct exit routine in web, merger 2022-10-05 13:25:07 -07:00
web.py Correct exit routine in web, merger 2022-10-05 13:25:07 -07:00