Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

background query not executed with pg_background_detach(pg_background_launch('...')) #6

Open
radist-nt opened this issue May 11, 2018 · 1 comment

Comments

@radist-nt
Copy link

radist-nt commented May 11, 2018

Steps to reproduce the problem:

  1. Open two sessions for database (S1 and S2)
  2. Execute LISTEN test_background; in S1
  3. Execute NOTIFY test_background, '1';select pg_background_detach(pg_background_launch('NOTIFY test_background, ''2'';')); in S2
  4. Execute SELECT; in S1

Expected result: two notification messages with payloads 1 and 2 in S1.
Actual result: single notification message with payload 1.

Looks like pg_background_detach terminates pg_background_launch call (with rollback). Inserting pg_sleep(0.1) between pg_background_launch and pg_background_detach solves the problem.

PostgreSQL version: "PostgreSQL 9.6.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11), 64-bit"

@rjuju
Copy link
Collaborator

rjuju commented May 16, 2021

Hi,

As far as I can see this is the same problem as reported in #1, as the logs show:

2021-05-16 23:04:07.711 CST [27600] ERROR:  unable to map dynamic shared memory segment
2021-05-16 23:04:07.713 CST [26820] LOG:  background worker "pg_background" (PID 27600) exited with exit code 1

So until this problem is fixed, you can either avoid to call pg_background_detach(), or call instead pg_background_result()

@rjuju rjuju added feature and removed bug labels May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants