diff --git a/master/buildbot/db/build_data.py b/master/buildbot/db/build_data.py index 5ac33a50d9e..70687a1688a 100644 --- a/master/buildbot/db/build_data.py +++ b/master/buildbot/db/build_data.py @@ -167,14 +167,13 @@ def thd(conn) -> int: q = q.where( (builds.c.complete_at >= older_than_timestamp) | (builds.c.complete_at == NULL) ) + # n.b.: in sqlite we need to filter on `>= older_than_timestamp` because of the following `NOT IN` clause... q = build_data.delete().where(build_data.c.buildid.notin_(q)) else: q = build_data.delete() q = q.where(builds.c.id == build_data.c.buildid) - q = q.where( - (builds.c.complete_at >= older_than_timestamp) | (builds.c.complete_at == NULL) - ) + q = q.where(builds.c.complete_at <= older_than_timestamp) res = conn.execute(q) conn.commit() res.close() diff --git a/newsfragments/janitor-timehorizon.bugfix b/newsfragments/janitor-timehorizon.bugfix new file mode 100644 index 00000000000..b3e7f21d31d --- /dev/null +++ b/newsfragments/janitor-timehorizon.bugfix @@ -0,0 +1 @@ +Fixes the timestamp comparison in janitor: it should cleanup builds 'older than' given timestamp - previously janitor would delete all build_data for builds 'newer than' the configured build data horizon. \ No newline at end of file