You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/07/05 15:35:09 UTC

[GitHub] [rocketmq-client-go] fengberlin opened a new issue #698: The cancel function created by context.WithTimeout should be called

fengberlin opened a new issue #698:
URL: https://github.com/apache/rocketmq-client-go/issues/698


   In the latest release `rocketmq-client-go` sdk (version [2.1.0](https://github.com/apache/rocketmq-client-go/releases/tag/v2.1.0), the `cancel` function is not be called, this will cause memory/resources leak.
   
   e.g. in the producer.go, line [#244](https://github.com/apache/rocketmq-client-go/blob/2bdc662c91c92aa0f68a90f1db5a3c4b6e677db0/producer/producer.go#L244) :
   > ctx, _ = context.WithTimeout(ctx, 3*time.Second)
   
   According to the go doc:
   > WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)).
   > Canceling this context releases resources associated with it, so code should
   > call cancel as soon as the operations running in this Context complete:
   
   ```
   func slowOperationWithTimeout(ctx context.Context) (Result, error) {
    	ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
   	defer cancel()  // releases resources if slowOperation completes before timeout elapses
   	return slowOperation(ctx)
   }
   ```


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq-client-go] fengberlin commented on issue #698: The cancel function created by context.WithTimeout should be called

Posted by GitBox <gi...@apache.org>.
fengberlin commented on issue #698:
URL: https://github.com/apache/rocketmq-client-go/issues/698#issuecomment-874200913


   This is my PR #691


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq-client-go] fengberlin commented on issue #698: The cancel function created by context.WithTimeout should be called

Posted by GitBox <gi...@apache.org>.
fengberlin commented on issue #698:
URL: https://github.com/apache/rocketmq-client-go/issues/698#issuecomment-874200913


   This is my PR #691


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq-client-go] maixiaohai closed issue #698: The cancel function created by context.WithTimeout should be called

Posted by GitBox <gi...@apache.org>.
maixiaohai closed issue #698:
URL: https://github.com/apache/rocketmq-client-go/issues/698


   


-- 
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: dev-unsubscribe@rocketmq.apache.org

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



[GitHub] [rocketmq-client-go] wenfengwang commented on issue #698: The cancel function created by context.WithTimeout should be called

Posted by GitBox <gi...@apache.org>.
wenfengwang commented on issue #698:
URL: https://github.com/apache/rocketmq-client-go/issues/698#issuecomment-882326967


   revert `defer cancel()`  of InvokeAsync in https://github.com/apache/rocketmq-client-go/pull/702


-- 
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: dev-unsubscribe@rocketmq.apache.org

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