| 301 | |
| 302 | @pytest.mark.crdb_skip("backend pid") |
| 303 | def test_inerror_rollback(dsn, caplog): |
| 304 | caplog.set_level(logging.WARNING, logger="psycopg.pool") |
| 305 | pids = [] |
| 306 | |
| 307 | def worker(): |
| 308 | with p.connection() as conn: |
| 309 | pids.append(conn.info.backend_pid) |
| 310 | assert conn.info.transaction_status == TransactionStatus.IDLE |
| 311 | |
| 312 | with pool.NullConnectionPool(dsn, max_size=1) as p: |
| 313 | conn = p.getconn() |
| 314 | |
| 315 | # Queue the worker so it will take the connection a second time instead |
| 316 | # of making a new one. |
| 317 | t = spawn(worker) |
| 318 | ensure_waiting(p) |
| 319 | |
| 320 | pids.append(conn.info.backend_pid) |
| 321 | with pytest.raises(psycopg.ProgrammingError): |
| 322 | conn.execute("wat") |
| 323 | assert conn.info.transaction_status == TransactionStatus.INERROR |
| 324 | p.putconn(conn) |
| 325 | gather(t) |
| 326 | |
| 327 | assert pids[0] == pids[1] |
| 328 | assert len(caplog.records) == 1 |
| 329 | assert "INERROR" in caplog.records[0].message |
| 330 | |
| 331 | |
| 332 | @pytest.mark.crdb_skip("backend pid") |