nodece commented on code in PR #1502:
URL: https://github.com/apache/pulsar-client-go/pull/1502#discussion_r3332506349


##########
pulsar/blue_green_migration_test.go:
##########
@@ -159,14 +161,29 @@ func testTopicMigrate(
                        }
 
                        pm := ProducerMessage{Payload: 
[]byte(fmt.Sprintf("hello-%d", i))}
+                       retryStarted := time.Now()
 
                        for true {
                                ctx, cancel := 
context.WithTimeout(context.Background(), 1*time.Second)
-                               defer cancel()
                                _, err := producer.Send(ctx, &pm)
+                               cancel()
                                if err == nil {
                                        break
                                }
+                               if errors.Is(err, ErrTopicTerminated) || 
errors.Is(err, ErrProducerClosed) {
+                                       select {
+                                       case errCh <- fmt.Errorf("producer 
became terminal during migration at message %d: %w", i, err):
+                                       default:
+                                       }

Review Comment:
   I intentionally used a non-blocking send here to avoid potential deadlocks. 
If `errCh` is no longer being consumed (or the buffer is full), a blocking send 
could prevent the migration goroutine from exiting cleanly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to