Skip to content

Add blocking queue rate limit - #2555

Merged
tylerkaraszewski merged 62 commits into
mainfrom
stites-blockingQueueRateLimit
May 12, 2026
Merged

Add blocking queue rate limit#2555
tylerkaraszewski merged 62 commits into
mainfrom
stites-blockingQueueRateLimit

Conversation

@stitesExpensify

@stitesExpensify stitesExpensify commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Details

This PR blocks users from adding to the blocking queue if they already have too many commands in the queue. This prevents a single user from being able to DOS us (intentionally or on accident).

Once the queue is empty for 30 seconds, we reset the block list and allow those users to continue using the product per usual

Fixed Issues

https://github.com/Expensify/Expensify/issues/568969

Tests

Added automated tests


Internal Testing Reminder: when changing bedrock, please compile auth against your new changes

@stitesExpensify stitesExpensify self-assigned this Mar 19, 2026
Comment thread BedrockServer.cpp Outdated
@stitesExpensify
stitesExpensify marked this pull request as ready for review March 20, 2026 22:37

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a2a67d343

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread BedrockServer.cpp Outdated
Comment thread BedrockServer.cpp Outdated
@stitesExpensify

Copy link
Copy Markdown
Contributor Author

@codex review again

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 836f8a0f3a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread BedrockServer.cpp Outdated
Comment thread BedrockServer.cpp Outdated
@stitesExpensify

Copy link
Copy Markdown
Contributor Author

This is my first bedrock PR ever, let me know if anything needs to be changed! I realize that a lot of the comments are a mixture of "what is happening" and "why is it happening", but it made it a lot more clear to me. Happy to remove them if they are unnecessary to people more familiar with the codebase

@melvin-bot

melvin-bot Bot commented Mar 26, 2026

Copy link
Copy Markdown

I see this code uses list. If your primary use case is just checking to see if an item exists in the list, perhaps set is a better choice, as it's much faster for random access. C++ has a variety of data structures available to choose from, so pick the best for your use case.

Comment thread BedrockCommand.h Outdated
Comment thread BedrockServer.h Outdated
Comment thread BedrockServer.h Outdated
Comment thread BedrockBlockingCommandQueue.h Outdated
Comment thread BedrockBlockingCommandQueue.h Outdated
Comment thread BedrockServer.cpp Outdated
Comment thread BedrockBlockingCommandQueue.cpp Outdated
Comment thread BedrockBlockingCommandQueue.cpp Outdated
@stitesExpensify

Copy link
Copy Markdown
Contributor Author

Okay this is ready for review again! The merge conflicts were due to a pretty big structure change, so things had to be moved around. I disabled the actual throw and left the log so that we can test before actually enabling

Comment thread BedrockBlockingCommandQueue.cpp
Comment thread BedrockBlockingCommandQueue.cpp Outdated
Comment thread BedrockBlockingCommandQueue.h Outdated
Comment thread BedrockBlockingCommandQueue.cpp Outdated
@stitesExpensify

Copy link
Copy Markdown
Contributor Author

UPdated with suggestions, but tests are failing now (we just don't see it here because we disabled the tests since we're only logging)

@flodnv flodnv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this, I'm eager to see it in action!

Comment thread BedrockCommand.h Outdated
Comment thread BedrockServer.cpp Outdated
Comment thread BedrockServer.cpp Outdated
Comment thread BedrockBlockingCommandQueue.cpp Outdated
Comment thread BedrockBlockingCommandQueue.cpp Outdated
@stitesExpensify

Copy link
Copy Markdown
Contributor Author

Okay we should be good to go here!

flodnv
flodnv previously approved these changes May 7, 2026

@flodnv flodnv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All yours @tylerkaraszewski

@flodnv
flodnv requested review from cead22 and tylerkaraszewski May 7, 2026 14:12
cead22
cead22 previously approved these changes May 7, 2026
Comment thread BedrockBlockingCommandQueue.cpp Outdated
@stitesExpensify
stitesExpensify dismissed stale reviews from cead22 and flodnv via ce1932c May 7, 2026 21:16
@tylerkaraszewski
tylerkaraszewski merged commit 1acee64 into main May 12, 2026
8 checks passed
@tylerkaraszewski
tylerkaraszewski deleted the stites-blockingQueueRateLimit branch May 12, 2026 16:30
}

count++;
if (count > maxPerIdentifier) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wait what, this if (count > maxPerIdentifier) { is the same as line 36 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

lol oops, looks like copy/pasta to me, or maybe a relic of when there were 2 different identifiers. PR to de-duplicate here #2615

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think I need another change there, please hold

@stitesExpensify stitesExpensify May 26, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay it's ready now, there was another error in the same spot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants