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

chore: skip publishing the last empty struct when generator stops #2327

Merged
merged 4 commits into from
Jan 13, 2025

Conversation

KeranYang
Copy link
Member

@KeranYang KeranYang commented Jan 13, 2025

closes #2285

There is race condition when we terminate the generator vertex. The message channel can be closed followed by a read from the channel. Reading from a closed channel will return the zero value of the struct, resulting in an empty message being sent to the next vertex. This change prevent it from being sent so that we have a consistent data structure for downstream vertices.

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 67.08%. Comparing base (ade70d8) to head (d1aaa02).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/sources/generator/tickgen.go 25.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2327      +/-   ##
==========================================
- Coverage   67.09%   67.08%   -0.02%     
==========================================
  Files         351      351              
  Lines       45269    45272       +3     
==========================================
- Hits        30375    30372       -3     
- Misses      13825    13829       +4     
- Partials     1069     1071       +2     

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

// when the channel is closed and empty, go will still read from the channel once and return the zero value.
// exclude the zero value from being passed to the next vertex,
// ensuring all messages produced by generator follow the same data schema.
if util.IsZeroStruct(r) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is it zerostruct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! I updated the PR description and addressed the comment. Don't need the isZero check, just use the second parameter should work.

// ensuring all messages produced by generator follow the same data schema.
if !ok {
mg.logger.Info("Zero value read from the generator channel, skipping...")
continue
Copy link
Member

Choose a reason for hiding this comment

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

In this case, shall we return instead of continue?

.
Signed-off-by: Keran Yang <[email protected]>
@KeranYang KeranYang marked this pull request as ready for review January 13, 2025 22:55
@KeranYang KeranYang requested a review from vigith as a code owner January 13, 2025 22:55
@KeranYang KeranYang merged commit 2922173 into main Jan 13, 2025
28 checks passed
@KeranYang KeranYang deleted the generator-schema branch January 13, 2025 23:33
SaniyaKalamkar pushed a commit to SaniyaKalamkar/numaflow that referenced this pull request Jan 19, 2025
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.

UDSink receives one unexpected message during shutdown
2 participants