hasura / hasura/graphql-engine
Hasura 2.42.0 regresssion connectivity to PostgreSQL read only db
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Version Information
Server Version: 2.42.0
CLI Version (for CLI related issue):
### Environment
OSS
### What is the current behaviour?
I'm attaching hot standby postgresdb and hasura fails with:
`{"detail":{"http_info":{"content_encoding":null,"http_version":"HTTP/1.0","ip":"172.28.63.18","method":"POST","status":500,"url":"/v2/query"},"operation":{"error":{"code":"postgres-error","error":"postgres tx error","internal":{"arguments":[],"error":{"description":null,"exec_status":"FatalError","hint":null,"message":"cannot set transaction read-write mode during recovery","status_code":"0A000"},"prepared":true,"statement":"BEGIN ISOLATION LEVEL READ COMMITTED READ WRITE"},"path":"$"},"query":{"args":{"source":"Replicated","sql":"SELECT VERSION()"},"type":"run_sql"},"query_execution_time":6.270142e-3,"request_id":"6a78c842-bd77-4c22-b33a-1da06841ebcb","request_mode":"error","request_read_time":1.41e-6,"response_size":327,"uncompressed_response_size":327,"user_vars":{"x-hasura-role":"admin"}},"request_id":"6a78c842-bd77-4c22-b33a-1da06841ebcb"},"level":"error","span_id":"d87a0e9b79825cc4","timestamp":"2024-11-05T10:45:43.256+0000","trace_id":"3f335bf56449eb9f5cc0fe745c98ba19","type":"http-log"} `
When switching to master node all works fully correct. If I run select version(); by hand on replicated DB using the same user as hasura does I got result. Looks like hasura is trying to do some kind of lock on the db while on readonly node it is not possible.
I'm using separate PostgreSQL DB as metadata database. So it looks like a regression.
### What is the expected behaviour?
Database should be connected and all objects should be visible.
### How to reproduce the issue?
1. Build a physically replicated PostgreSQL server
2. Enable Feature Flags:
- New Relationship tab UI for tables/views
- Enable new Table Tracking UI for Postgres & SQL Server
- Data Tab Performance Mode
3. Try to connect to replicated node
### Screenshots or Screencast

### Please provide any traces or logs that could help here.
### Any possible solutions/workarounds you're aware of?
It looks like if the metadata will be build upon head node you can still query the slave node for data.
### Keywords
cannot set transaction read-write mode during recovery
Contributor guide
Research direction
Start by reproducing the /v2/query run_sql request against a physically replicated PostgreSQL node and inspect where the transaction begins with READ WRITE during recovery. Done means Hasura connects to the read-only node, exposes its objects, and the SELECT VERSION() request succeeds without the read-write transaction error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100