Skip to content

Losing connection to database #2060

Description

@BabyYeggie

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

Teslamate seems to be losing connection to postgres 12. This is causing no data to be stored. Currently running on a GCP E2 instance running Debian 10 buster v20210122.

Expected Behavior

Data is stored as intended

Steps To Reproduce

Start Teslamate as normal using the "advanced" set up.

Relevant log output

Attaching to postgres
postgres     | 
postgres     | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres     | 
postgres     | 2021-10-11 06:58:16.717 UTC [1] LOG:  starting PostgreSQL 12.8 (Debian 12.8-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
postgres     | 2021-10-11 06:58:16.763 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres     | 2021-10-11 06:58:16.763 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgres     | 2021-10-11 06:58:16.931 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres     | 2021-10-11 06:58:17.589 UTC [25] LOG:  database system was shut down at 2021-10-11 06:54:16 UTC
postgres     | 2021-10-11 06:58:18.085 UTC [1] LOG:  database system is ready to accept connections
postgres     | 2021-10-12 01:17:51.153 UTC [39] LOG:  unexpected EOF on client connection with an open transaction
postgres     | 2021-10-12 01:17:52.771 UTC [2252] LOG:  PID 39 in cancel request did not match any process
postgres     | 2021-10-12 14:16:13.745 UTC [38] ERROR:  canceling statement due to user request
postgres     | 2021-10-12 14:16:13.745 UTC [38] STATEMENT:  SELECT s0."count", s0."start_position_id", s0."end_position_id", s0."outside_temp_avg", s0."inside_temp_avg", s0."speed_max", s0."power_max", s0."power_min", s0."start_date", s0."end_date", s0."start_km", s0."end_km", s0."distance", s0."duration_min", s0."start_ideal_range_km", s0."end_ideal_range_km", s0."start_rated_range_km", s0."end_rated_range_km", s1."start_ideal_range_km", s1."end_ideal_range_km", s1."start_rated_range_km", s1."end_rated_range_km" FROM (SELECT count(*) OVER "w" AS "count", first_value(sp0."id") OVER "w" AS "start_position_id", last_value(sp0."id") OVER "w" AS "end_position_id", avg(sp0."outside_temp") OVER "w" AS "outside_temp_avg", avg(sp0."inside_temp") OVER "w" AS "inside_temp_avg", max(sp0."speed") OVER "w" AS "speed_max", max(sp0."power") OVER "w" AS "power_max", min(sp0."power") OVER "w" AS "power_min", first_value(sp0."date") OVER "w" AS "start_date", last_value(sp0."date") OVER "w" AS "end_date", first_value(sp0."odometer") OVER "w" AS "start_km", last_value(sp0."odometer") OVER "w" AS "end_km", last_value(sp0."odometer") OVER "w" - first_value(sp0."odometer") OVER "w" AS "distance", round(extract(epoch from (last_value(sp0."date") OVER "w" - first_value(sp0."date") OVER "w")) / 60)::integer AS "duration_min", -1 AS "start_ideal_range_km", -1 AS "end_ideal_range_km", -1 AS "start_rated_range_km", -1 AS "end_rated_range_km" FROM "positions" AS sp0 WHERE (sp0."drive_id" = $1) WINDOW "w" AS (ORDER BY sp0."date" RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) LIMIT 1) AS s0 INNER JOIN (SELECT first_value(sp0."ideal_battery_range_km") OVER "w" AS "start_ideal_range_km", last_value(sp0."ideal_battery_range_km") OVER "w" AS "end_ideal_range_km", first_value(sp0."rated_battery_range_km") OVER "w" AS "start_rated_range_km", last_value(sp0."rated_battery_range_km") OVER "w" AS "end_rated_range_km" FROM "positions" AS sp0 WHERE (((sp0."drive_id" = $2) AND NOT (sp0."ideal_battery_range_km" IS NULL)) AND NOT (sp0."odometer" IS NULL)) WINDOW "w" AS (ORDER BY sp0."date" RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) LIMIT 1) AS s1 ON TRUE
postgres     | 2021-10-12 14:16:14.098 UTC [38] LOG:  could not send data to client: Broken pipe
postgres     | 2021-10-12 14:16:14.098 UTC [38] FATAL:  connection to client lost
postgres     | 2021-10-12 14:39:25.287 UTC [2253] LOG:  unexpected EOF on client connection with an open transaction
postgres     | 2021-10-12 19:02:59.522 UTC [3860] ERROR:  canceling statement due to user request
postgres     | 2021-10-12 19:02:59.522 UTC [3860] STATEMENT:  SELECT s0."drive_id" FROM (SELECT sp0."drive_id" AS "drive_id", count(*) FILTER (WHERE NOT (sp0."odometer" IS NULL) AND (sp0."ideal_battery_range_km" IS NULL)) AS "streamed_count" FROM "positions" AS sp0 WHERE (NOT (sp0."drive_id" IS NULL)) GROUP BY sp0."drive_id") AS s0 WHERE (s0."streamed_count" = 0)
postgres     | 2021-10-12 19:02:59.624 UTC [4434] FATAL:  terminating connection due to administrator command
postgres     | 2021-10-12 14:16:14.098 UTC [38] LOG:  could not send data to client: Broken pipe
postgres     | 2021-10-12 14:16:14.098 UTC [38] FATAL:  connection to client lost
postgres     | 2021-10-12 14:39:25.287 UTC [2253] LOG:  unexpected EOF on client connection with an open transaction
postgres     | 2021-10-12 19:02:59.522 UTC [3860] ERROR:  canceling statement due to user request
postgres     | 2021-10-12 19:02:59.522 UTC [3860] STATEMENT:  SELECT s0."drive_id" FROM (SELECT sp0."drive_id" AS "drive_id", count(*) FILTER (WHERE NOT (sp0."odometer" IS NULL) AND (sp0."ideal_battery_range_km" IS NULL)) AS "streamed_count" FROM "positions" AS sp0 WHERE (NOT (sp0."drive_id" IS NULL)) GROUP BY sp0."drive_id") AS s0 WHERE (s0."streamed_count" = 0)
postgres     | 2021-10-12 19:02:59.624 UTC [4434] FATAL:  terminating connection due to administrator command
postgres     | 2021-10-12 19:02:59.624 UTC [4434] STATEMENT:  SELECT s0."drive_id" FROM (SELECT sp0."drive_id" AS "drive_id", count(*) FILTER (WHERE NOT (sp0."odometer" IS NULL) AND (sp0."ideal_battery_range_km" IS NULL)) AS "streamed_count" FROM "positions" AS sp0 WHERE (NOT (sp0."drive_id" IS NULL)) GROUP BY sp0."drive_id") AS s0 WHERE (s0."streamed_count" = 0)
postgres     | 2021-10-12 19:02:59.624 UTC [4435] FATAL:  terminating connection due to administrator command
postgres     | 2021-10-12 19:02:59.624 UTC [4435] STATEMENT:  SELECT s0."drive_id" FROM (SELECT sp0."drive_id" AS "drive_id", count(*) FILTER (WHERE NOT (sp0."odometer" IS NULL) AND (sp0."ideal_battery_range_km" IS NULL)) AS "streamed_count" FROM "positions" AS sp0 WHERE (NOT (sp0."drive_id" IS NULL)) GROUP BY sp0."drive_id") AS s0 WHERE (s0."streamed_count" = 0)
postgres     | 2021-10-12 19:02:59.716 UTC [1] LOG:  background worker "parallel worker" (PID 4435) exited with exit code 1
postgres     | 2021-10-12 19:02:59.716 UTC [1] LOG:  background worker "parallel worker" (PID 4434) exited with exit code 1
postgres     | 2021-10-12 19:03:00.152 UTC [3860] LOG:  could not send data to client: Broken pipe
postgres     | 2021-10-12 19:03:00.152 UTC [3860] FATAL:  connection to client lost
postgres     | 2021-10-13 14:18:26.297 UTC [36] ERROR:  canceling statement due to user request

Screenshots

No response

Additional data

While no drive data is stored, the "visited" and "trip" map is accurate and shows the proper trips.

Type of installation

Docker

Version

v1.24.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions