HikariPool Connection Timeout Issue - Connection is not available, request timed out after 30000ms

Hamzaa month ago

Hello everyone,

I’m encountering an issue with the HikariCP connection pool in Traccar. Here’s the error I’m seeing:

HikariPool-1 - Connection is not available, request timed out after 30000ms (total=10, active=10, idle=0, waiting=253) - SQLTransientConnectionException (... < QueryBuilder:67 < *:140 < DatabaseStorage:72 < DeviceResource:128 < ... < OverrideFilter:49 < ...)

I think this issue is caused by the daily database cleanup cron job. Is there any solution for this?

Anton Tananaeva month ago

What does your cleanup job look like?

Hamza25 days ago
#!/bin/bash
result=""
while [[ "$result" != *" 0 rows affected"* ]]; do
  result=$(mysql -u traccar1 -pPassword new_d -vve "DELETE FROM tc_positions WHERE fixTime < DATE(DATE_ADD(NOW(), INTERVAL -60 DAY)) AND id NOT IN (SELECT positionId FROM tc_devices WHERE positionid IS NOT NULL) LIMIT 10000")
  sleep 1
done
result=""
while [[ "$result" != *" 0 rows affected"* ]]; do
  result=$(mysql -u traccar1 -pPassword new_d -vve "DELETE FROM tc_events WHERE eventTime < DATE(DATE_ADD(NOW(), INTERVAL -60 DAY)) LIMIT 10000")
  sleep 1
done
Anton Tananaev25 days ago

And do you have the right indexes? How does does it take to execute each query?