clean build_reservations table
This commit is contained in:
parent
54d6630345
commit
ba54425854
3 changed files with 25 additions and 2 deletions
|
|
@ -115,6 +115,8 @@ Metadata will be provided by the Content Generator as a JSON file. There
|
|||
is a proposal of the :doc:`Content Generator
|
||||
Metadata <content_generator_metadata>` format available for review.
|
||||
|
||||
.. _cg_api:
|
||||
|
||||
API
|
||||
===
|
||||
|
||||
|
|
|
|||
|
|
@ -518,11 +518,19 @@ appropriate age setting. Default value of one day should be ok for most
|
|||
deployments. As there will be tons of freed records, additional VACUUM can be
|
||||
handy.
|
||||
|
||||
::
|
||||
.. code-block:: sql
|
||||
|
||||
DELETE FROM sessions WHERE update_time < now() - '1 day'::interval;
|
||||
DELETE FROM sessions WHERE update_time < NOW() - '1 day'::interval;
|
||||
VACUUM ANALYZE sessions;
|
||||
|
||||
Optionally (if you're using :ref:`reservation API <cg_api>` for
|
||||
content generators), you could want to run also reservation cleanup:
|
||||
|
||||
.. code-block:: sql
|
||||
|
||||
DELETE FROM build_reservations WHERE update_time < NOW() - '1 day'::interval;
|
||||
VACUUM ANALYZE build_reservations;
|
||||
|
||||
Set User/Password Authentication
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,18 @@ def clean_sessions(cursor, vacuum):
|
|||
cursor.execute("VACUUM ANALYZE sessions")
|
||||
|
||||
|
||||
def clean_reservations(cursor, vacuum):
|
||||
q = " FROM build_reservations WHERE create_time < now() - '1 day'::interval"
|
||||
if options.verbose:
|
||||
cursor.execute("SELECT COUNT(*) " + q)
|
||||
rows = cursor.fetchall()[0][0]
|
||||
print("Deleting %d build reservations" % rows)
|
||||
|
||||
cursor.execute("DELETE " + q)
|
||||
if vacuum:
|
||||
cursor.execute("VACUUM ANALYZE build_reservations")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
global options
|
||||
parser = OptionParser("%prog cleans koji database")
|
||||
|
|
@ -72,4 +84,5 @@ if __name__ == "__main__":
|
|||
cursor = conn.cursor()
|
||||
|
||||
clean_sessions(cursor, options.vacuum)
|
||||
clean_reservations(cursor, options.vacuum)
|
||||
conn.commit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue