fix: Restore showing LISTEN pgrst in pg_stat_activity

This commit is contained in:
Michal Kleczek
2026-04-30 17:21:12 -05:00
committed by GitHub
parent 5f6f7dca44
commit 04a0e041e4
3 changed files with 36 additions and 1 deletions
+1
View File
@@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. From versio
- Fix login with uppercase and mixed case role names by @taimoorzaeem in #4678 - Fix login with uppercase and mixed case role names by @taimoorzaeem in #4678
- Remove automatic transaction retries on `40001 (serialization_failure)` errors to prevent replication lag by @laurenceisla in #3673 - Remove automatic transaction retries on `40001 (serialization_failure)` errors to prevent replication lag by @laurenceisla in #3673
- Fix unexpected results when embedding and filtering the same table more than once by @laurenceisla in #4075 - Fix unexpected results when embedding and filtering the same table more than once by @laurenceisla in #4075
- Restore Listener query shape so it can be found in pg_stat_activity by @mkleczek in #4857 #4859
### Changed ### Changed
+1 -1
View File
@@ -68,9 +68,9 @@ retryingListen appState = do
-- use connection -- use connection
\case \case
Right db -> do Right db -> do
SQL.listen db $ SQL.toPgIdentifier dbChannel
(pqHost, pqPort) <- SQL.withLibPQConnection db $ bisequence . (LibPQ.host &&& LibPQ.port) (pqHost, pqPort) <- SQL.withLibPQConnection db $ bisequence . (LibPQ.host &&& LibPQ.port)
pgFullName <- SQL.run queryPgVersion db >>= either throwIO (pure . pgvFullName) pgFullName <- SQL.run queryPgVersion db >>= either throwIO (pure . pgvFullName)
SQL.listen db $ SQL.toPgIdentifier dbChannel
AppState.putIsListenerOn appState True AppState.putIsListenerOn appState True
+34
View File
@@ -3,6 +3,7 @@
import os import os
import re import re
import signal import signal
import subprocess
import time import time
import pytest import pytest
@@ -690,6 +691,39 @@ def test_admin_ready_w_channel(defaultenv):
assert response.status_code == 200 assert response.status_code == 200
def test_listener_query_is_visible_in_pg_stat_activity(defaultenv):
"The listener connection should show the LISTEN pgrst statement in pg_stat_activity"
env = {
**defaultenv,
"PGRST_DB_CHANNEL_ENABLED": "true",
"PGAPPNAME": "listener-query-test",
}
with run(env=env):
query = """
select query
from pg_stat_activity
where application_name = 'listener-query-test'
and query = 'LISTEN "pgrst"'
limit 1;
"""
output = subprocess.check_output(
[
"psql",
"--set",
"ON_ERROR_STOP=1",
"--tuples-only",
"--no-align",
"-c",
query,
],
text=True,
).strip()
assert output == 'LISTEN "pgrst"'
def test_admin_ready_wo_channel(defaultenv): def test_admin_ready_wo_channel(defaultenv):
"Should get a success response from the admin server ready endpoint when the LISTEN channel is disabled" "Should get a success response from the admin server ready endpoint when the LISTEN channel is disabled"