Skip to content
New issue

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

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

Already on GitHub? # to your account

What happens if workers are not available? #65

Open
brankoradovanovic-mcom opened this issue Dec 19, 2024 · 0 comments
Open

What happens if workers are not available? #65

brankoradovanovic-mcom opened this issue Dec 19, 2024 · 0 comments

Comments

@brankoradovanovic-mcom
Copy link

The answer is: pg_background_launch() will throw INSUFFICIENT_RESOURCES.

If pg_background is used for logging, this is a particularly unpleasant failure mode because:

  1. Whatever message one tried to insert into the log table will be lost, and
  2. The job that was being logged in this way will probably break, and
  3. The above will happen once in a while, in an unpredictable way

One might play with the settings for max_worker_processes and max_parallel_workers, but this will not eliminate the problem, it will just make it less likely to happen.

Of course, if workers are not available, pg_background itself can't do much about it. Trouble is, the caller can't do much either. The best I've come up with is to catch the exception, do pg_sleep() for some interval, then retry. Is there a better way to handle it?

I think the documentation should at least mention this issue. If the above analysis is correct, I feel this is a significant limitation of autonomous transactions when implemented through pg_background.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant