You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/08/24 17:59:42 UTC

[GitHub] [pulsar-client-go] wuYin opened a new pull request #359: Reconsume

wuYin opened a new pull request #359:
URL: https://github.com/apache/pulsar-client-go/pull/359


   Fixes #353 
   
   ### Motivation
   
   Follow [pulsar#6449](https://github.com/apache/pulsar/pull/6449) to support retry letter topic in go client
   
   ### Modifications
   
   - Add `retryRouter` for sending reconsume messages to retry letter topic
   - Add `ReconsumeLater(msg Message, delay time.Duration)` to Consumer interface
   - Add configureable retry letter topic name in `DLQPolicy`
       ```go
   	type DLQPolicy struct {
   		// ...
   		// Name of the topic where the retry messages will be sent.
   		RetryLetterTopic string
   	}
   	```
       enable it explicitly while creating consumer, default enabled
      
        ```go
       type ConsumerOptions struct {
   	    // ...
   		// Auto retry send messages to default filled DLQPolicy topics
   		RetryEnable bool
   	}
       ```
   - Add 3 `TestRLQ*`  test cases
   
   
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   ### Documentation
   [pulsar doc: retry-letter-topic](http://pulsar.apache.org/docs/en/concepts-messaging/#retry-letter-topic)


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] wolfstudy commented on a change in pull request #359: Support retry letter topic

Posted by GitBox <gi...@apache.org>.
wolfstudy commented on a change in pull request #359:
URL: https://github.com/apache/pulsar-client-go/pull/359#discussion_r485635022



##########
File path: pulsar/internal/connection.go
##########
@@ -356,24 +357,35 @@ func (c *connection) run() {
 	defer func() {
 		// all the accesses to the pendingReqs should be happened in this run loop thread,
 		// including the final cleanup, to avoid the issue https://github.com/apache/pulsar-client-go/issues/239
+		c.pendingLock.Lock()
 		for id, req := range c.pendingReqs {
 			req.callback(nil, errors.New("connection closed"))
 			delete(c.pendingReqs, id)
 		}
+		c.pendingLock.Unlock()
 		c.Close()
 	}()
 
+	go func() {
+		for {
+			select {
+			case <-c.closeCh:
+				return
+
+			case req := <-c.incomingRequestsCh:
+				if req == nil {
+					return // TODO: this never gonna be happen
+				}
+				c.internalSendRequest(req)
+			}
+		}
+	}()
+

Review comment:
       Cool, LGTM +1




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] wuYin commented on a change in pull request #359: Support retry letter topic

Posted by GitBox <gi...@apache.org>.
wuYin commented on a change in pull request #359:
URL: https://github.com/apache/pulsar-client-go/pull/359#discussion_r485617154



##########
File path: pulsar/internal/connection.go
##########
@@ -356,24 +357,35 @@ func (c *connection) run() {
 	defer func() {
 		// all the accesses to the pendingReqs should be happened in this run loop thread,
 		// including the final cleanup, to avoid the issue https://github.com/apache/pulsar-client-go/issues/239
+		c.pendingLock.Lock()
 		for id, req := range c.pendingReqs {
 			req.callback(nil, errors.New("connection closed"))
 			delete(c.pendingReqs, id)
 		}
+		c.pendingLock.Unlock()
 		c.Close()
 	}()
 
+	go func() {
+		for {
+			select {
+			case <-c.closeCh:
+				return
+
+			case req := <-c.incomingRequestsCh:
+				if req == nil {
+					return // TODO: this never gonna be happen
+				}
+				c.internalSendRequest(req)
+			}
+		}
+	}()
+

Review comment:
       Background:
   - Retry topic producer, User topic consumer, they two use same connection instance to interact with broker.
   - Request channel, Response channel, they two are listened in a [single `select{}` loop](https://github.com/apache/pulsar-client-go/blob/master/pulsar/internal/connection.go#L367) by a connection.
   
   When message need to be redelivery:
   1. Retry topic producer called `SendAsync()`, wrapped User topic consumer AckID logic as **callback** into message handler.
   2. connection send cmd `SEND` to broker.
   3. Broker send cmd  `SEND_RECEIPT` to connection.
   4. connection received and call  **callback**
   5. **callback** called `AckID()`, then connection want to send cmd `ACK`  to broker.
   in the meantime, `select{}` was stucked in step 3 and  executing `SEND_RECEIPT` handler, `incomingRequestsCh` never be chosen, when it fulled with 10 Ack requests, finnally lead to dead block.
   
   Asynchronized reuquest & response channels in connection, this block will be resolved.
   
   
   ![deadblock](https://user-images.githubusercontent.com/24536920/92602248-7d7a8900-f2e0-11ea-8fed-46e6d6c05310.jpg)
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] wolfstudy merged pull request #359: Support retry letter topic

Posted by GitBox <gi...@apache.org>.
wolfstudy merged pull request #359:
URL: https://github.com/apache/pulsar-client-go/pull/359


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] wuYin commented on pull request #359: Support retry letter topic

Posted by GitBox <gi...@apache.org>.
wuYin commented on pull request #359:
URL: https://github.com/apache/pulsar-client-go/pull/359#issuecomment-682318139


   run integration tests


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] wuYin removed a comment on pull request #359: Support retry letter topic

Posted by GitBox <gi...@apache.org>.
wuYin removed a comment on pull request #359:
URL: https://github.com/apache/pulsar-client-go/pull/359#issuecomment-682318139


   run integration tests


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] wolfstudy commented on a change in pull request #359: Support retry letter topic

Posted by GitBox <gi...@apache.org>.
wolfstudy commented on a change in pull request #359:
URL: https://github.com/apache/pulsar-client-go/pull/359#discussion_r485559504



##########
File path: pulsar/internal/connection.go
##########
@@ -356,24 +357,35 @@ func (c *connection) run() {
 	defer func() {
 		// all the accesses to the pendingReqs should be happened in this run loop thread,
 		// including the final cleanup, to avoid the issue https://github.com/apache/pulsar-client-go/issues/239
+		c.pendingLock.Lock()
 		for id, req := range c.pendingReqs {
 			req.callback(nil, errors.New("connection closed"))
 			delete(c.pendingReqs, id)
 		}
+		c.pendingLock.Unlock()
 		c.Close()
 	}()
 
+	go func() {
+		for {
+			select {
+			case <-c.closeCh:
+				return
+
+			case req := <-c.incomingRequestsCh:
+				if req == nil {
+					return // TODO: this never gonna be happen
+				}
+				c.internalSendRequest(req)
+			}
+		}
+	}()
+

Review comment:
       @wuYin Why do we need to do this?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org