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

Fix regression: not respecting interval in read_with_poll #343

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

v0idpwn
Copy link
Collaborator

@v0idpwn v0idpwn commented Nov 15, 2024

The regression happened in the port to PL/pgSQL.

Division of integers on postgres yields integer results. Our unit conversion from milliseconds to seconds didn't consider that, and returned wrong results. This caused pgmq.read_with_poll to sleep 0s instead of poll_interval_ms if poll_interval_ms was under 1000, using 100% of CPU.

The fix is simply converting poll_interval_ms to numeric before doing the division, which produces a numeric result as originally intended.

The regression happened in the port to PL/pgSQL.

Division of integers on postgres yields integer results. Our unit conversion from
milliseconds to seconds didn't consider that, then returning wrong results.
This caused `pgmq.read_with_poll` to sleep 0s instead of `poll_interval_ms`
if `poll_interval_ms` was under 1000, using 100% of CPU.

The fix is simply converting `poll_interval_ms` to `numeric` before doing the
division, which produces a `numeric` result as originally intended.
@v0idpwn v0idpwn marked this pull request as ready for review November 15, 2024 01:25
@v0idpwn v0idpwn merged commit 897f666 into main Nov 15, 2024
19 checks passed
@v0idpwn v0idpwn deleted the fix/busy-waiting-read_with_poll branch November 15, 2024 04:37
ChuckHend pushed a commit that referenced this pull request Nov 15, 2024
* Fix regression: not respecting interval in read_with_poll

The regression happened in the port to PL/pgSQL.

Division of integers on postgres yields integer results. Our unit conversion from
milliseconds to seconds didn't consider that, then returning wrong results.
This caused `pgmq.read_with_poll` to sleep 0s instead of `poll_interval_ms`
if `poll_interval_ms` was under 1000, using 100% of CPU.

The fix is simply converting `poll_interval_ms` to `numeric` before doing the
division, which produces a `numeric` result as originally intended.

* Fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants