diff --git a/docs/source/content_generators.rst b/docs/source/content_generators.rst index fcbe31d4..4acbd8c0 100644 --- a/docs/source/content_generators.rst +++ b/docs/source/content_generators.rst @@ -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 ` format available for review. +.. _cg_api: + API === diff --git a/docs/source/server_howto.rst b/docs/source/server_howto.rst index a1e630f4..59834d4d 100644 --- a/docs/source/server_howto.rst +++ b/docs/source/server_howto.rst @@ -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 ` 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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/util/koji-sweep-db b/util/koji-sweep-db index 39e305f2..8a83df24 100755 --- a/util/koji-sweep-db +++ b/util/koji-sweep-db @@ -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()