-
Notifications
You must be signed in to change notification settings - Fork 882
Description
Is there an existing issue for this?
- I have searched the existing issues
What happened?
Since some time the postgres container is running on high load (load around 4) while the car is sleeping.
Behavior was visible with postgres version 13 and is the same after upgrade to version 16.
Stopping the teslamate container reduces the load immediatly as restarting it will start the high load again.
Based on the logs the following behavior is seen:
Teslamate runs a query:
(STATEMENT: SELECT p0."id", p0."date", p0."latitude", p0."longitude", p0."elevation", p0."speed", p0."power", p0."odometer", p0."ideal_battery_range_km", p0."est_battery_range_km", p0."rated_battery_range_km", p0."battery_level", p0."usable_battery_level", p0."battery_heater", p0."battery_heater_on", p0."battery_heater_no_power", p0."outside_temp", p0."inside_temp", p0."fan_status", p0."driver_temp_setting", p0."passenger_temp_setting", p0."is_climate_on", p0."is_rear_defroster_on", p0."is_front_defroster_on", p0."tpms_pressure_fl", p0."tpms_pressure_fr", p0."tpms_pressure_rl", p0."tpms_pressure_rr", p0."car_id", p0."drive_id" FROM "positions" AS p0 WHERE (((p0."id" > $1) AND (p0."elevation" IS NULL)) AND p0."drive_id" = ANY($2)) ORDER BY p0."id" LIMIT $3)
which times out after 60000 ms. After 2 seconds the query is started again.
In rare situations it seems the query can finish, then the load is reduced to a normal value for some hours but restarting again later. It looks like the problem comes up more often with the growing size of the database (DB Backup size now 3 GB)
Teslamate is running on a Raspi4 with 4 GB of RAM. There are some other containers running (iobroker) on the system. Normal load without teslamate running is around 0,25, with teslamate running and postgres high load it is running at a load around 4 all the time
Expected Behavior
Perhabs increasing the timeout for the query can help or some other optimizations to reduce the query time omn
Steps To Reproduce
No response
Relevant log output
2024-09-26 20:35:00.815 [error] Postgrex.Protocol (#PID<0.2455.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.39063.0> timed out because it queued and checked out the connection for longer than 60000ms
#PID<0.39063.0> was at location:
:prim_inet.recv0/3
(postgrex 0.17.3) lib/postgrex/protocol.ex:3188: Postgrex.Protocol.msg_recv/4
(postgrex 0.17.3) lib/postgrex/protocol.ex:2213: Postgrex.Protocol.recv_bind/3
(postgrex 0.17.3) lib/postgrex/protocol.ex:2105: Postgrex.Protocol.bind_execute/4
(db_connection 2.6.0) lib/db_connection/holder.ex:354: DBConnection.Holder.holder_apply/4
(db_connection 2.6.0) lib/db_connection.ex:1512: DBConnection.run_execute/5
(db_connection 2.6.0) lib/db_connection.ex:1607: DBConnection.run/6
(db_connection 2.6.0) lib/db_connection.ex:743: DBConnection.parsed_prepare_execute/5
2024-09-26 20:35:00.825 [error] GenStateMachine TeslaMate.Terrain terminating
** (DBConnection.ConnectionError) tcp recv: closed (the connection was closed by the pool, possibly due to a timeout or because the pool has been terminated)
(ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:1047: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto_sql 3.10.2) lib/ecto/adapters/sql.ex:945: Ecto.Adapters.SQL.execute/6
(ecto 3.10.3) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4
(ecto 3.10.3) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
(teslamate 1.30.1) lib/teslamate/log.ex:197: TeslaMate.Log.get_positions_without_elevation/2
(teslamate 1.30.1) lib/teslamate/terrain.ex:77: TeslaMate.Terrain.handle_event/4
(stdlib 5.2.3) gen_statem.erl:1397: :gen_statem.loop_state_callback/11
(stdlib 5.2.3) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Database Logs (same time):
2024-09-26 20:35:00.819 UTC [9696] ERROR: canceling statement due to user request
2024-09-26 20:35:00.819 UTC [9696] STATEMENT: SELECT p0."id", p0."date", p0."latitude", p0."longitude", p0."elevation", p0."speed", p0."power", p0."odometer", p0."ideal_battery_range_km", p0."est_battery_range_km", p0."rated_battery_range_km", p0."battery_level", p0."usable_battery_level", p0."battery_heater", p0."battery_heater_on", p0."battery_heater_no_power", p0."outside_temp", p0."inside_temp", p0."fan_status", p0."driver_temp_setting", p0."passenger_temp_setting", p0."is_climate_on", p0."is_rear_defroster_on", p0."is_front_defroster_on", p0."tpms_pressure_fl", p0."tpms_pressure_fr", p0."tpms_pressure_rl", p0."tpms_pressure_rr", p0."car_id", p0."drive_id" FROM "positions" AS p0 WHERE (((p0."id" > $1) AND (p0."elevation" IS NULL)) AND p0."drive_id" = ANY($2)) ORDER BY p0."id" LIMIT $3
2024-09-26 20:35:00.819 UTC [9794] FATAL: terminating background worker "parallel worker" due to administrator command
2024-09-26 20:35:00.819 UTC [9794] STATEMENT: SELECT p0."id", p0."date", p0."latitude", p0."longitude", p0."elevation", p0."speed", p0."power", p0."odometer", p0."ideal_battery_range_km", p0."est_battery_range_km", p0."rated_battery_range_km", p0."battery_level", p0."usable_battery_level", p0."battery_heater", p0."battery_heater_on", p0."battery_heater_no_power", p0."outside_temp", p0."inside_temp", p0."fan_status", p0."driver_temp_setting", p0."passenger_temp_setting", p0."is_climate_on", p0."is_rear_defroster_on", p0."is_front_defroster_on", p0."tpms_pressure_fl", p0."tpms_pressure_fr", p0."tpms_pressure_rl", p0."tpms_pressure_rr", p0."car_id", p0."drive_id" FROM "positions" AS p0 WHERE (((p0."id" > $1) AND (p0."elevation" IS NULL)) AND p0."drive_id" = ANY($2)) ORDER BY p0."id" LIMIT $3
2024-09-26 20:35:00.820 UTC [9795] FATAL: terminating background worker "parallel worker" due to administrator command
2024-09-26 20:35:00.820 UTC [9795] STATEMENT: SELECT p0."id", p0."date", p0."latitude", p0."longitude", p0."elevation", p0."speed", p0."power", p0."odometer", p0."ideal_battery_range_km", p0."est_battery_range_km", p0."rated_battery_range_km", p0."battery_level", p0."usable_battery_level", p0."battery_heater", p0."battery_heater_on", p0."battery_heater_no_power", p0."outside_temp", p0."inside_temp", p0."fan_status", p0."driver_temp_setting", p0."passenger_temp_setting", p0."is_climate_on", p0."is_rear_defroster_on", p0."is_front_defroster_on", p0."tpms_pressure_fl", p0."tpms_pressure_fr", p0."tpms_pressure_rl", p0."tpms_pressure_rr", p0."car_id", p0."drive_id" FROM "positions" AS p0 WHERE (((p0."id" > $1) AND (p0."elevation" IS NULL)) AND p0."drive_id" = ANY($2)) ORDER BY p0."id" LIMIT $3
2024-09-26 20:35:00.844 UTC [1] LOG: background worker "parallel worker" (PID 9794) exited with exit code 1
2024-09-26 20:35:00.847 UTC [1] LOG: background worker "parallel worker" (PID 9795) exited with exit code 1Screenshots
No response
Additional data
No response
Type of installation
Docker
Version
v1.30.1