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

Closed reader does not return in Next #1218

Closed
Gilthoniel opened this issue May 15, 2024 · 3 comments · Fixed by #1219
Closed

Closed reader does not return in Next #1218

Gilthoniel opened this issue May 15, 2024 · 3 comments · Fixed by #1219

Comments

@Gilthoniel
Copy link
Contributor

Gilthoniel commented May 15, 2024

Expected behavior

After closing a reader, I would expect the Next function to return an error that the reader is closed.

Actual behavior

It blocks forever.

Steps to reproduce

Close the reader then call the Next, it will not return:

client, err := pulsar.NewClient(pulsar.ClientOptions{URL: "pulsar://localhost:6650"})
if err != nil { ... }

defer client.Close()

reader, err := client.CreateReader(pulsar.ReaderOptions{ ... })
if err != nil { ... }

reader.Close()

// Here I would expect to directly return an error but it blocks forever.
reader.Next(context.Background())

System configuration

Pulsar version: v3.0
Pulsar client: v12.1

@Gilthoniel
Copy link
Contributor Author

Gilthoniel commented May 15, 2024

A simple fix would be to add a case to the select to return when the consumer closed channel is closed but I don't know if that behavior is on purpose at the first place.

@RobertIndie
Copy link
Member

Thanks for reporting this.

An simple fix would be to add a case to the select to return when the consumer closed channel is closed

Yes. I think this should be correct behavior.

@Gilthoniel
Copy link
Contributor Author

Thanks @RobertIndie , I've opened #1219 for a potential fix.

RobertIndie pushed a commit that referenced this issue May 20, 2024
Fixes #1218 

### Motivation

Calling Next on a reader already closed will block forever unless the context is canceled. Similarly, the call will not return if a different go routine closes the reader.

### Modifications

Next now listens for the close channel of the consumer to return an error when it closes.

Signed-off-by: Gaylor Bosson <gb@taurusgroup.ch>
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 a pull request may close this issue.

2 participants