You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/06/12 14:17:01 UTC

[GitHub] [nifi-minifi-cpp] szaszm opened a new pull request #811: MINIFICPP-1257 don't leak kafka messages on failed send to broker

szaszm opened a new pull request #811:
URL: https://github.com/apache/nifi-minifi-cpp/pull/811


   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [x] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [x] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
   
   - [x] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [x] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [x] If applicable, have you updated the LICENSE file?
   - [x] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [x] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
   


----------------------------------------------------------------
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] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #811: MINIFICPP-1257 don't leak kafka messages on failed send to broker

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #811:
URL: https://github.com/apache/nifi-minifi-cpp/pull/811#discussion_r439988172



##########
File path: extensions/librdkafka/PublishKafka.h
##########
@@ -233,9 +233,13 @@ class PublishKafka : public core::Processor {
 
       const gsl::owner<rd_kafka_headers_t*> hdrs_copy = rd_kafka_headers_copy(hdrs.get());
       const auto err = rd_kafka_producev(rk_, RD_KAFKA_V_RKT(rkt_), RD_KAFKA_V_PARTITION(RD_KAFKA_PARTITION_UA), RD_KAFKA_V_MSGFLAGS(RD_KAFKA_MSG_F_COPY), RD_KAFKA_V_VALUE(buffer.data(), buflen),
-                                         RD_KAFKA_V_HEADERS(hdrs_copy), RD_KAFKA_V_KEY(key_.c_str(), key_.size()), RD_KAFKA_V_OPAQUE(callback_ptr.release()), RD_KAFKA_V_END);
-      if (err) {
-        // the message only takes ownership of the headers in case of success
+                                         RD_KAFKA_V_HEADERS(hdrs_copy), RD_KAFKA_V_KEY(key_.c_str(), key_.size()), RD_KAFKA_V_OPAQUE(callback_ptr.get()), RD_KAFKA_V_END);
+      if (err == RD_KAFKA_RESP_ERR_NO_ERROR) {
+        // in case of failure, messageDeliveryCallback is not called and callback_ptr will delete the callback
+        // in case of success, messageDeliveryCallback takes ownership of the callback, so we no longer need to delete it

Review comment:
       I'm not familiar with this processor, could we have a scenario where the messageDeliveryCallback is not eventually called?




----------------------------------------------------------------
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] [nifi-minifi-cpp] arpadboda closed pull request #811: MINIFICPP-1257 don't leak kafka messages on failed send to broker

Posted by GitBox <gi...@apache.org>.
arpadboda closed pull request #811:
URL: https://github.com/apache/nifi-minifi-cpp/pull/811


   


----------------------------------------------------------------
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] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #811: MINIFICPP-1257 don't leak kafka messages on failed send to broker

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #811:
URL: https://github.com/apache/nifi-minifi-cpp/pull/811#discussion_r439985423



##########
File path: extensions/librdkafka/PublishKafka.h
##########
@@ -233,9 +233,13 @@ class PublishKafka : public core::Processor {
 
       const gsl::owner<rd_kafka_headers_t*> hdrs_copy = rd_kafka_headers_copy(hdrs.get());
       const auto err = rd_kafka_producev(rk_, RD_KAFKA_V_RKT(rkt_), RD_KAFKA_V_PARTITION(RD_KAFKA_PARTITION_UA), RD_KAFKA_V_MSGFLAGS(RD_KAFKA_MSG_F_COPY), RD_KAFKA_V_VALUE(buffer.data(), buflen),
-                                         RD_KAFKA_V_HEADERS(hdrs_copy), RD_KAFKA_V_KEY(key_.c_str(), key_.size()), RD_KAFKA_V_OPAQUE(callback_ptr.release()), RD_KAFKA_V_END);
-      if (err) {
-        // the message only takes ownership of the headers in case of success
+                                         RD_KAFKA_V_HEADERS(hdrs_copy), RD_KAFKA_V_KEY(key_.c_str(), key_.size()), RD_KAFKA_V_OPAQUE(callback_ptr.get()), RD_KAFKA_V_END);
+      if (err == RD_KAFKA_RESP_ERR_NO_ERROR) {

Review comment:
       👍

##########
File path: extensions/librdkafka/PublishKafka.h
##########
@@ -233,9 +233,13 @@ class PublishKafka : public core::Processor {
 
       const gsl::owner<rd_kafka_headers_t*> hdrs_copy = rd_kafka_headers_copy(hdrs.get());
       const auto err = rd_kafka_producev(rk_, RD_KAFKA_V_RKT(rkt_), RD_KAFKA_V_PARTITION(RD_KAFKA_PARTITION_UA), RD_KAFKA_V_MSGFLAGS(RD_KAFKA_MSG_F_COPY), RD_KAFKA_V_VALUE(buffer.data(), buflen),
-                                         RD_KAFKA_V_HEADERS(hdrs_copy), RD_KAFKA_V_KEY(key_.c_str(), key_.size()), RD_KAFKA_V_OPAQUE(callback_ptr.release()), RD_KAFKA_V_END);
-      if (err) {
-        // the message only takes ownership of the headers in case of success
+                                         RD_KAFKA_V_HEADERS(hdrs_copy), RD_KAFKA_V_KEY(key_.c_str(), key_.size()), RD_KAFKA_V_OPAQUE(callback_ptr.get()), RD_KAFKA_V_END);
+      if (err == RD_KAFKA_RESP_ERR_NO_ERROR) {
+        // in case of failure, messageDeliveryCallback is not called and callback_ptr will delete the callback
+        // in case of success, messageDeliveryCallback takes ownership of the callback, so we no longer need to delete it

Review comment:
       I'm not familiar with this processor, I assume messageDeliveryCallback is async called, could we have a scenario where the messageDeliveryCallback is not eventually called?




----------------------------------------------------------------
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] [nifi-minifi-cpp] arpadboda commented on a change in pull request #811: MINIFICPP-1257 don't leak kafka messages on failed send to broker

Posted by GitBox <gi...@apache.org>.
arpadboda commented on a change in pull request #811:
URL: https://github.com/apache/nifi-minifi-cpp/pull/811#discussion_r440227046



##########
File path: extensions/librdkafka/PublishKafka.h
##########
@@ -233,9 +233,13 @@ class PublishKafka : public core::Processor {
 
       const gsl::owner<rd_kafka_headers_t*> hdrs_copy = rd_kafka_headers_copy(hdrs.get());
       const auto err = rd_kafka_producev(rk_, RD_KAFKA_V_RKT(rkt_), RD_KAFKA_V_PARTITION(RD_KAFKA_PARTITION_UA), RD_KAFKA_V_MSGFLAGS(RD_KAFKA_MSG_F_COPY), RD_KAFKA_V_VALUE(buffer.data(), buflen),
-                                         RD_KAFKA_V_HEADERS(hdrs_copy), RD_KAFKA_V_KEY(key_.c_str(), key_.size()), RD_KAFKA_V_OPAQUE(callback_ptr.release()), RD_KAFKA_V_END);
-      if (err) {
-        // the message only takes ownership of the headers in case of success
+                                         RD_KAFKA_V_HEADERS(hdrs_copy), RD_KAFKA_V_KEY(key_.c_str(), key_.size()), RD_KAFKA_V_OPAQUE(callback_ptr.get()), RD_KAFKA_V_END);
+      if (err == RD_KAFKA_RESP_ERR_NO_ERROR) {
+        // in case of failure, messageDeliveryCallback is not called and callback_ptr will delete the callback
+        // in case of success, messageDeliveryCallback takes ownership of the callback, so we no longer need to delete it

Review comment:
       As far as I understand the API documentation, in case this function returns no error, the callback should be called. 




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