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(rate-limit): consider paused queue #1931

Merged
merged 4 commits into from
Jun 5, 2023
Merged

Conversation

roggervalf
Copy link
Collaborator

No description provided.

local pttl = rcall("PTTL", rateLimiterKey)

if pttl <= 0 then
rcall("DEL", rateLimiterKey)
Copy link
Collaborator Author

@roggervalf roggervalf Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can delete the key here if it's 0

-- remove from active queue and add back to the wait list
rcall("LREM", keys[2], 1, jobId)
rcall("RPUSH", keys[1], jobId)
rcall("RPUSH", targetKey, jobId)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider paused queue, not only wait list

@@ -67,6 +67,11 @@ end
if jobId then
if string.sub(jobId, 1, 2) == "0:" then
rcall("LREM", KEYS[2], 1, jobId)

if expireTime > 0 then
return { 0, 0, expireTime, 0 }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we delete the previous marker, if expireTime is greater than 0 (in rate-limit), we can return expireTime

@roggervalf roggervalf requested a review from manast June 1, 2023 02:55
});
});

await delay(500);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in order to get drained attribute as true for all workers

@roggervalf roggervalf merged commit d97864a into master Jun 5, 2023
@roggervalf roggervalf deleted the fix-rate-limit-finish branch June 5, 2023 21:21
github-actions bot pushed a commit that referenced this pull request Jun 5, 2023
## [3.15.1](v3.15.0...v3.15.1) (2023-06-05)

### Bug Fixes

* **rate-limit:** consider paused queue ([#1931](#1931)) ([d97864a](d97864a))

### Features

* **python:** add changePriority method ([#1943](#1943)) ([945bcd3](945bcd3))
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.

1 participant