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

Return an error in the leader is not ready yet #98

Merged
merged 5 commits into from
Nov 2, 2021
Merged

Conversation

Gsantomaggio
Copy link
Member

leader is not ready yet, add also a small fix in the aggregation

fixes #96

leader is not ready yet, add also a small fix in the aggregation
Copy link
Contributor

@victorges victorges left a comment

Choose a reason for hiding this comment

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

LGTM!

pkg/stream/client.go Outdated Show resolved Hide resolved
pkg/stream/client.go Outdated Show resolved Hide resolved
leader is not ready yet, add also a small fix in the aggregation
@Gsantomaggio
Copy link
Member Author

@victorges ready for another round.

now you can do something like:

if err != nil {
	if errors.Is(err, stream.LeaderNotReady) {..}
       if errors.Is(err, stream.ReplicaNotReady) {..}
      if errors.Is(err, stream.StreamNotAvailable) {..}

....
}

@codecov-commenter
Copy link

codecov-commenter commented Oct 31, 2021

Codecov Report

Merging #98 (e44501f) into main (e191752) will decrease coverage by 0.43%.
The diff coverage is 20.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #98      +/-   ##
==========================================
- Coverage   79.49%   79.05%   -0.44%     
==========================================
  Files          16       16              
  Lines        2390     2402      +12     
==========================================
- Hits         1900     1899       -1     
- Misses        357      368      +11     
- Partials      133      135       +2     
Impacted Files Coverage Δ
pkg/stream/constants.go 70.17% <0.00%> (-8.26%) ⬇️
pkg/stream/enviroment.go 71.02% <0.00%> (ø)
pkg/stream/client.go 79.53% <10.00%> (-1.24%) ⬇️
pkg/stream/aggregation.go 62.89% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e191752...e44501f. Read the comment docs.

@@ -135,6 +141,12 @@ func lookErrorCode(errorCode uint16) error {
return FrameTooLarge
case responseCodeAccessRefused:
return CodeAccessRefused
case responseCodeStreamNotAvailable:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! I think I did see some "unknown response code" errors or something like that, will be helpful to have these.


for _, replica := range streamMetadata.Replicas {
if replica == nil {
return nil, ReplicaNotReady
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should only filter the nil elements instead of a fatal error if any of them is not present?

For example, if only the leader and 1 replica from a 3 member cluster are available, should we not connect to the cluster at all or should we just connect to one of the online members? I'd generally assume the latter, but I'm not sure if it works differently for streams.

So as a concrete idea, I'd suggest moving this loop to the point where we append to the final brokers slice (line 633 rn), and instead of returning an error we just skip (continue) the nil brokers, only appending the non-nil replicas one-by-one to the slice. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not totally sure to understand. Can you please fork the repo e propose a PR to my branch ? With your suggestions ?
Thank you

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure! Will do tomorrow when I get back to the computer ok?
Sorry for the confusion

Copy link
Member Author

Choose a reason for hiding this comment

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

No problem at all :)
Thank you for your contributions!

Copy link
Contributor

Choose a reason for hiding this comment

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

Just created a PR, to merge on the branch of this current PR, with the suggested fix!

#100

@Gsantomaggio
Copy link
Member Author

Ok, @victorges we finally did it :) thank you!

We have to close #99 and #43 then we can release the first RC.

The first RC introduces a couple of breaking changes.

@Gsantomaggio Gsantomaggio merged commit 71eff1d into main Nov 2, 2021
@Gsantomaggio Gsantomaggio deleted the aggregation_fix branch November 2, 2021 11:18
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.

panic: nil reference when target server is down
3 participants