Repository navigation
[fix][tableview] Fix watchReaderForNewMessages to exit silently on normal shutdown and skip nil messages on error - #1557
Conversation
…rmal shutdown and skip nil messages on error
|
@crossoverJie Hello, can you help me review this PR |
There was a problem hiding this comment.
🟡 Changes recommended
The regression tests need assertions for silent shutdown and actual message processing after a transient error.
2 open issues
What changed in this PR
This PR improves the TableView reader loop’s error handling so normal shutdown is silent and failed reads skip message processing.
Changes:
- Exit before logging when the reader closes or the context is canceled.
- Continue to the next read after logging other errors.
- Add mock-based tests for shutdown and recovery after transient errors.
| File | Description |
|---|---|
pulsar/table_view_test.go |
Adds reader and message mocks plus three watcher tests. |
pulsar/table_view_impl.go |
Handles shutdown before logging and skips message handling on read errors. |
Review effort: Balanced
…rmal shutdown and skip nil messages on error
|
@crossoverJie Hello, I have made revisions based on the feedback. Please help me review them |
|
@zjxxzjwang Could you rebase this onto the current master? |
|
1 similar comment
|
|
@crossoverJie There are no other issues here, can you help me with the final approval |

Motivation
When a
TableViewis closed,Close()callsreader.Close()which causesreader.Next()to return aConsumerClosederror. However, the existingwatchReaderForNewMessageshad two problems:Error log on normal shutdown: The error check (
ConsumerClosed/context.Canceled) was placed after theErrorfcall, so every normal close would emit a spurious error log before the goroutine exited.Nil message passed to
handleMessageon error: Whenreader.Next()returned a non-fatal error, the code fell through tohandleMessage(msg)with a potentiallynilmessage. Although amsg != nilguard existed, the lack ofcontinuemeant the control flow was fragile and confusing.Modifications
ConsumerClosed/context.Canceledexit check inside theerr != nilblock, before the error log, so the goroutine exits silently on normal shutdown without logging.continueafter logging non-fatal errors to skip message handling entirely whenmsgmay benil.mockReaderto verify:TestWatchReaderExitsOnConsumerClosed— exits immediately onConsumerClosed.TestWatchReaderExitsOnContextCanceled— exits immediately on context cancellation.TestWatchReaderRecoversFromTransientError— survives a transient error, delivers the next valid message, then exits onConsumerClosed.Verifying this change
This change added tests and can be verified as follows:
TestWatchReaderExitsOnConsumerClosedto verify the goroutine exits without furtherNextcalls whenConsumerClosedis returned.TestWatchReaderExitsOnContextCanceledto verify the goroutine exits when the context is cancelled.TestWatchReaderRecoversFromTransientErrorto verify the loop continues after a transient error, processes a subsequent valid message, and finally exits onConsumerClosed.Does this pull request potentially affect one of the following parts:
Documentation