Skip to content

Commit 6371d93

Browse files
authored
Adjust device_connections worker frequency, increase timeout when deleting in batches (#1839)
- Increases the frequency of `DeleteOldDeviceConnections` and offsets it by a minute to ensure we're not stacking jobs on the hour - Sets timeout for `delete_all` to 30s so DB has enough time to work
1 parent 9bd4680 commit 6371d93

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

config/config.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ config :nerves_hub, Oban,
7171
crontab: [
7272
{"0 * * * *", NervesHub.Workers.ScheduleOrgAuditLogTruncation},
7373
{"*/1 * * * *", NervesHub.Workers.CleanStaleDeviceConnections},
74-
{"0 */1 * * *", NervesHub.Workers.DeleteOldDeviceConnections},
74+
{"1,16,31,46 * * * *", NervesHub.Workers.DeleteOldDeviceConnections},
7575
{"*/5 * * * *", NervesHub.Workers.ExpireInflightUpdates},
7676
{"*/15 * * * *", NervesHub.Workers.DeviceHealthTruncation}
7777
]}

lib/nerves_hub/devices/connections.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ defmodule NervesHub.Devices.Connections do
139139
{delete_count, _} =
140140
DeviceConnection
141141
|> where([d], d.id in subquery(query))
142-
|> Repo.delete_all()
142+
|> Repo.delete_all(timeout: 30_000)
143143

144144
if delete_count == 0 do
145145
:ok

0 commit comments

Comments
 (0)