Hi, I’m encountering an issue for quite some time where I’m unable to remove the Gateway device from the Chirpstack Portal.
When I tried to delete the gateway, it takes a long time and then this error showed from the Inspect element:
{"error": "storage transaction rollback error: driver: bad connection:, "code":2, "message":"storage: transaction rollback error: driver: bad connection", :details: []}
After this failed to remove the gateway, suddenly the client connected to the Postgres database keep on increasing. I checked the pg_stat_activity table and found these Locked queries:
The first one is the Delete Query:
delete from gateway where mac = $1
and after that, these queries keep on piling up:
select g.* from gateway g inner join network_server ns on ns.id = g.network_server_id where ns.gateway_discovery_enabled = true and g.ping = true and (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval '24 hours' / ns.gateway_discovery_interval))) order by last_ping_sent_at limit 1 for update
May I ask how do I fix this? Since I’m unable to delete most of the gateways. I only able to delete around 3 and I have around 100+ gateway in total.
Thank you
Here is one example from pg_stat_activity:
datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_start | state_change | wait_event_type | wait_event | state | backend_xid | backend_xmin | query | backend_type
--------+---------------+-------+----------+---------------+------------------+---------------+-----------------+-------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-----------------+---------------------+--------+-------------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------
613766 | loraserver_as | 17744 | 16385 | loraserver_as | | 10.105.130.30 | | 54844 | 2023-06-27 11:10:03.660701+08 | 2023-06-27 11:10:12.209167+08 | 2023-06-27 11:10:12.211396+08 | 2023-06-27 11:10:12.211396+08 | Lock | tuple | active | 774543070 | 774542835 | delete from gateway where mac = $1 | client backend
613766 | loraserver_as | 16406 | 16385 | loraserver_as | | 10.105.130.30 | | 20454 | 2023-06-27 11:07:36.071354+08 | 2023-06-27 11:08:48.83109+08 | 2023-06-27 11:08:48.831648+08 | 2023-06-27 11:08:48.83165+08 | Lock | tuple | active | | 774542835 | +| client backend
| | | | | | | | | | | | | | | | | | select +|
| | | | | | | | | | | | | | | | | | g.* +|
| | | | | | | | | | | | | | | | | | from gateway g +|
| | | | | | | | | | | | | | | | | | inner join network_server ns +|
| | | | | | | | | | | | | | | | | | on ns.id = g.network_server_id +|
| | | | | | | | | | | | | | | | | | where +|
| | | | | | | | | | | | | | | | | | ns.gateway_discovery_enabled = true +|
| | | | | | | | | | | | | | | | | | and g.ping = true +|
| | | | | | | | | | | | | | | | | | and (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval '24 hours' / ns.gateway_discovery_interval))) +|
| | | | | | | | | | | | | | | | | | order by last_ping_sent_at +|
| | | | | | | | | | | | | | | | | | limit 1 +|
| | | | | | | | | | | | | | | | | | for update |