Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
- Make sure `LISTEN <db-channel>` query is present in pg_stat_activity row corresponding to session established by notification listening thread by @mkleczek in #4857 #4859
Comment thread
steve-chavez marked this conversation as resolved.
Outdated

### Changed

Expand Down
2 changes: 1 addition & 1 deletion src/PostgREST/Listener.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ retryingListen appState = do
-- use connection
\case
Right db -> do
SQL.listen db $ SQL.toPgIdentifier dbChannel
(pqHost, pqPort) <- SQL.withLibPQConnection db $ bisequence . (LibPQ.host &&& LibPQ.port)
pgFullName <- SQL.run queryPgVersion db >>= either throwIO (pure . pgvFullName)
SQL.listen db $ SQL.toPgIdentifier dbChannel

AppState.putIsListenerOn appState True

Expand Down
34 changes: 34 additions & 0 deletions test/io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
import signal
import subprocess
import time
import pytest

Expand Down Expand Up @@ -690,6 +691,39 @@ def test_admin_ready_w_channel(defaultenv):
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()
Comment thread
steve-chavez marked this conversation as resolved.

assert output == 'LISTEN "pgrst"'


def test_admin_ready_wo_channel(defaultenv):
"Should get a success response from the admin server ready endpoint when the LISTEN channel is disabled"

Expand Down
Loading