Aditya Oza
07/06/2026, 4:09 PMCleanupExpiredHosts cron job (the expired_hosts job within cleanups_then_aggregation).
Our setup:
• ~9M hosts in Fleet, only ~100k actively checking in
• Host expiry is enabled, but stale hosts aren't being removed
Error:
Root cause: Three code paths pass the full list of expired host IDs into unboundedget host details for expired hosts: select hosts by id: Error 1390 (HY000): Prepared statement contains too many placeholders
IN (?) clauses, which blows past MySQL's ~65,535 placeholder limit:
• ListHostsLiteByIDs
• DELETE FROM host_seen_times
• CleanupHostActivities
Related issues:
• This looks related to github.com/fleetdm/fleet/issues/31157 which was reported by another customer and closed. The symptoms are the same — hosts not being removed after hitting the expiry window — but at our scale the prepared statement limit is the specific failure mode.
• Also wanted to ask about github.com/fleetdm/fleet/issues/45947 — is there a timeline or release planned for a fix?
Our fix:
I've wrapped the three unbounded IN clauses with BatchProcessSimple .
github.com/adityaoza1901/…/cleanup-expired-hosts-batchingSteven Palmesano
07/06/2026, 4:30 PMSteven Palmesano
07/06/2026, 4:34 PMUnthread
07/08/2026, 5:38 PMUnthread
07/16/2026, 11:51 AMAditya Oza
07/21/2026, 9:24 PMUnthread
07/22/2026, 11:38 AMSteven Palmesano
07/22/2026, 11:49 AM