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 race conditions in the concatenate engine streaming #16640

Merged
merged 4 commits into from
Aug 26, 2024

Conversation

GuptaManan100
Copy link
Member

@GuptaManan100 GuptaManan100 commented Aug 23, 2024

Description

While looking at the flaky test pointed out in #16641 we found several issues in concatenate engine primitive in the streaming mode. The following are the issues and the fixes in this PR -

  1. In the parallel streaming mode, when we calculate the final field types for the result usinggetFieldTypes, we were overriding the fields of one of the result packets that we got. If this was a packet from a source that needed coercion, because we overwrote the fields, with what we expect them to be, when we check if coercion is required we end up with false even when it requires coercion. This is fixed in the PR by storing the result fields separately and checking for needing coercion with the original fields of the result.
  2. Another failure that was found was in the sequential streaming mode. This failure was also masked by the fact that we were not copying the rows when returning the result set in fake primitive. So the only time this test would fail was when ☝️ failed too. If that passed this would pass as well. We have fixed the tests as part of this PR to copy the rows as well before returning them since the concatenate engine modifies them so each test wasn't running with the desired inputs.
    The problem was that we were checking for needing coercion per result packet. But in the streaming mode, if a source is sending multiple packets, then only the first packet will have the fields and the others won't. This leads to the concatenate engine only coercing values in the first packet and not in the subsequent ones since there are no fields. The fix was to check for needing coercion once for a given source and use it for all its packets.
  3. Final failure was found after noticing that in the test we weren't checking for the fields in the stream execute output. This has been fixed wherein we now verify we get the correct fields from stream execute as well. Moreover, another check has been added that ensures that all the fields returned as part of the results should match. Previously we would only fix the fields in the first packet that was sent, but the remaining packets could have incorrect names and field types in them because we never overwrote them. The fix is to only send fields for the first result and empty them out for all the others.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Copy link
Contributor

vitess-bot bot commented Aug 23, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Aug 23, 2024
@github-actions github-actions bot added this to the v21.0.0 milestone Aug 23, 2024
@GuptaManan100 GuptaManan100 added Type: Bug Component: Query Serving and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Aug 23, 2024
@GuptaManan100 GuptaManan100 marked this pull request as ready for review August 23, 2024 08:37
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 94.28571% with 2 lines in your changes missing coverage. Please review.

Project coverage is 68.98%. Comparing base (538dd4c) to head (bcec73c).
Report is 8 commits behind head on main.

Files Patch % Lines
go/vt/vtgate/engine/concatenate.go 94.28% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16640      +/-   ##
==========================================
- Coverage   68.98%   68.98%   -0.01%     
==========================================
  Files        1562     1562              
  Lines      200690   200740      +50     
==========================================
+ Hits       138449   138476      +27     
- Misses      62241    62264      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GuptaManan100 GuptaManan100 added the Backport to: release-20.0 Needs to be backport to release-20.0 label Aug 26, 2024
@GuptaManan100 GuptaManan100 merged commit d95e36f into vitessio:main Aug 26, 2024
130 checks passed
@GuptaManan100 GuptaManan100 deleted the concatenate-engine-fix branch August 26, 2024 06:20
vitess-bot pushed a commit that referenced this pull request Aug 26, 2024
@GuptaManan100 GuptaManan100 added Backport to: release-20.0 Needs to be backport to release-20.0 and removed Backport to: release-20.0 Needs to be backport to release-20.0 labels Aug 26, 2024
GuptaManan100 pushed a commit that referenced this pull request Aug 26, 2024
#16640) (#16648)

Signed-off-by: Manan Gupta <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
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.

Bug Report: Flaky test in concatenate engine exposes a real issue
3 participants