Fix Fetch Request Bug - Discard Remaining Response Data on Error #1177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses a bug in the Fetch request handling logic. Currently, when an error occurs while reading the header (e.g., OffsetOutOfRange error), the buffer is not returned with the batch, and neither is the remaining response data discarded (specifically the records field in the response that is set to null, as it is a NULLABLE type). The non-discarded bytes remain as a prefix in the buffer. This leads to failures in the correlation ID verification for the next message.
To resolve this issue, we have implemented a fix that discards the remaining bytes in case of an error during Fetch request processing. This ensures that leftover data from previous erroneous responses does not affect subsequent requests.
Changes
Testing
Due to the nature of this bug and the absence of utility to generate responses with errors in the conn_test file, it was challenging to create specific tests for this scenario. However, we have thoroughly reviewed and manually tested the changes to ensure the correctness and stability of the implementation.