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

Fixes try_execute_command message parsing bug #560

Merged

Conversation

zainkabani
Copy link
Contributor

@zainkabani zainkabani commented Aug 24, 2023

We were double reading the length of the message, this was masked when we had longer queries where we could read those extra bytes without causing an issue. A ruby health check change uncovered that when sending something like ; as a query we were running into panics because the buffer did not have the expected number of bytes.

@zainkabani zainkabani marked this pull request as ready for review August 24, 2023 18:22
@@ -1291,6 +1295,11 @@ mod test {
// Shard should start out unset
assert_eq!(qr.active_shard, None);

// Don't panic when short query eg. ; is sent
let q0 = simple_query(";");
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Happy to see test coverage here.

@levkk
Copy link
Contributor

levkk commented Aug 24, 2023

Really nice, thank you.

@levkk levkk merged commit be549f3 into postgresml:main Aug 24, 2023
@@ -150,9 +151,13 @@ impl QueryRouter {
|| self.pool_settings.sharding_key_regex.is_some()
{
// Check only the first block of bytes configured by the pool settings
let len = message_cursor.get_i32() as usize;
let seg = cmp::min(len - 5, self.pool_settings.regex_search_limit);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this variable unused now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's used in the seg calculation. It needs to be read off the cursor to progress the index that it's pointing to

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.

4 participants