1. 24 8月, 2020 1 次提交
    • Y
      [issue 7851][C++] Make clear() thread-safe (#7862) · 97f41120
      Yunze Xu 提交于
      Fixes #7851 
      
      ### Motivation
      
      `clear()` methods of `BatchAcknowledgementTracker` and `UnAckedMessageTrackerEnabled` are not thread-safe.
      
      ### Modifications
      
      Acquire a mutex in these `clear()` methods.
      97f41120
  2. 25 7月, 2020 1 次提交
  3. 05 7月, 2020 1 次提交
  4. 10 6月, 2020 1 次提交
    • Y
      Fix bug: pattern consumer's receive() will cause deadlock for topics auto discovery (#7206) · c2759be5
      Yunze Xu 提交于
      Fixes #7168 
      
      ### Motivation
      
      When a pattern consumer is blocked by `receive()`, the `mutex_` will be held until new messages arrived. If the auto discovery timer task found new topics and tried to subscribe them, `mutex_` must be acquired first, then the deadlock happened.
      
      ### Modifications
      
      - Release the `mutex_` after the consumer's state was verified.
      - Change unit tests to verify that new topics could be subscribed when the consumer's blocked by `receive(Message&)` or `receive(Message&, int)` methods.
      
      ### Verifying this change
      
      - [ ] Make sure that the change passes the CI checks.
      
      This change is already covered by existing tests, such as *BasicEndToEndTest.testPatternMultiTopicsConsumerAutoDiscovery*.
      c2759be5
  5. 08 6月, 2020 1 次提交
  6. 05 6月, 2020 1 次提交
    • T
      [Issue 6000][pulsar-client] C++ client ACK grouping feature. (#6534) · 9e4f854e
      Tong 提交于
      Fixes #6000 
      
      ### Motivation
      
      In our production environment, we created a sinker: It combines messages read from Pulsar, and writes the combined data into ClickHouse, which is not good at processing highly concurrent inserting (max. 100 QPS).
      
      In the sinker, we used failover subscription with cumulative ACK. The reason for not using shared subscription is that, individual ACK in C++ client siginificantly reduces throughput. Our analysis shows that huge amount of individual ACK requests results in highly concurrent accessing, which finally results in terrible throughput. BTW, the machines, where we deploy brokers and bookies, are not equipped with SSD. There could be some configuration for brokers or bookies helping improving the situation, but we don't find them.
      
      Therefore, the idea is that combining individual ACK requests within one request. After reading the protocol (PulsarApi.proto:CommandAck), we find that this feature is supported. According to this issue #6000 , Pulsar C++ client SDK does not implement ACK grouping feature, but it's already implemented by Java client.
      
      After discussing with @jiazhai and @sijie , we are authorized to implement this feature and contribute this feature back to community later. It should follow the Java client's behavior and provide similar interfaces that Java client provides.
      
      ### Modifications
      
      #### Interfaces
      
      Similar to Java client, C++ client implements three trackers to *cache* ACK requests within a configured time window:
      
      1. `AckGroupingTracker`: this is the base class of the other two trackers, it defines interfaces and provides empty implementation which does not send ACK requests to broker. This tracker is used for non-persistent topic, which actually does not require ACK.
      2. `AckGroupingTrackerDisabled`: child class of `AckGroupingTracker`. It does not provide ACK grouping ability, and acts just like the previous individual ACK.
      3. `AckGroupingTrackerEnabled`: child class of `AckGroupingTracker`. This is the real implementation of ACK grouping.
      
      The trackers provides following public interfaces:
      
      1. `isDuplicate`: checking if the given message ID exists in the TO-BE-ACKED group.
      2. `addAcknowledge` and `addAcknowledgeCumulative`: unlike Java client, which combines these two interfaces into one (`addAcknowledge`), C++ clients provides them for individual and cumulative ACK requests. Such design can provide slightly better performance than if-else implementation.
      3. `close`: closing the tracker.
      4. `flush` and `flushAndClean`: flushing all pending ACK requests, the later one also resets internal status.
      
      #### Consumer's Configuration
      
      Two new configuration options are added:
      
      1. `ackGroupingTimeMs`: time window in milliseconds for grouping ACK requests. If setting to positive value, ACK requests are grouped and sent to broker every `ackGroupingTimeMs` milliseconds (`AckGroupingTrackerEnabled`). For non-positive values, ACK requests are sent one by one to brokers as before (`AckGroupingTrackerDisabled`). Default is 100.
      2. `ackGroupingMaxSize`: maximum number of grouped message IDs. Java client hard-coded it to 1000 for now. However, 1000 is too small in our scenario. Once the grouped message number reaches this limit, the ACK requests will be packed into one and sent to broker, even the ACK grouping deadline (`ackGroupingTimeMs`) is not reached. Non-positive values remove such limit.
      
      **In addition**, these configurations are added into C API as well.
      
      #### Commands for this feature.
      
      A few new command factory interfaces are implemented, just like in Java, incl.
      
      * `newMultiMessageAck`: command object for multi-message ACK requests.
      * `peerSupports*`: interfaces for checking versions.
      
      #### Topic Domain
      
      Used to help defining and distinguish non-persistent and persistent topics.
      
      ### Verifying this change
      
      - [x] Make sure that the change passes the CI checks.
      
      This PR added 7 unit tests in `BasicEndToEndTest`, all of them start with `testAckGroupingTracker`. They cover the ACK grouping tracker's logic.
      
      ### Does this pull request potentially affect one of the following parts:
      
      NO
      
        - Dependencies (does it add or upgrade a dependency): (no)
        - The public API: (no)
        - The schema: (no)
        - The default values of configurations: (no)
        - The wire protocol: (no)
        - The rest endpoints: (no)
        - The admin cli options: (no)
        - Anything that affects deployment: (no)
      
      ### Documentation
      
        - Does this pull request introduce a new feature? (no)
        - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
        - If a feature is not applicable for documentation, explain why?
        - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
      9e4f854e
  7. 31 5月, 2020 1 次提交
    • M
      Fix flake in C++ negative acknowledgement tests (#7099) · ae324b1a
      Matteo Merli 提交于
      Negative acknowledgement runs in the background on a consumer and
      triggers redelivery of messages. The tests verify a that messages do
      indeed get redelivered, and which messages they are, for the base
      case, batching and partitioned consumer.
      
      There's a fundamental dependency on timing in the base case. If 100ms
      pass between consumer creation and receiving the last message in first
      receive loop, redelivery will be triggered and the order of messages,
      as asserted by the test will fail.
      
      This first case can be fixed by moving the negative ack to run after
      all messages have been received. However, this can also then fail for
      the batch case.
      
      If the negative ack tracker kicks off during the loop to negatively
      ack the messages, then the redelivery will happen twice (and possibly
      more times depending on how many time it manages to run).
      
      For this reason, if we want the test to be deterministic, we need to
      disable the tracker from kicking off redelivery while we send mark the
      messages as negatively acked.
      Co-authored-by: NIvan Kelly <ikelly@splunk.com>
      ae324b1a
  8. 30 5月, 2020 1 次提交
  9. 29 5月, 2020 1 次提交
    • M
      C++ tests should use sensible timeouts for receive (#7071) · b7a4fef3
      Matteo Merli 提交于
      ### Motivation
      
      A bunch of tests were using 100ms as the timeout for receive. 100ms is
      way too short. The broker for these tests is standalone, so everything
      is running in one process on one machine. I/O, locks, GC etc can
      easily make reads take longer than 100ms.
      
      We are testing functionality, not performance with these tests, so
      I've increased the timeout to 3s.
      b7a4fef3
  10. 19 5月, 2020 1 次提交
    • Y
      [C++] Release the unused spots of pending message queue (#6926) · 5bb8809a
      Yunze Xu 提交于
      ### Motivation
      
      If messages were sent in batch, every single message would reserve one spot of producer's pending message queue, but only one batched message would be pushed to the queue. Therefore there may exist many unused spots when `ProducerQueueIsFull` happened.
      
      Besides, if a message was too big or failed to be encrypted, `sendAsync` failed immediately but the reserved spot won't be released.
      
      ### Modifications
      
      - Add a `bool` return value to `BatchMessageContainer::sendMessages` to indicate whether the batched message was pushed to producer's queue.
      - Add a `bool` return value to `BatchMessageContainer::add` to indicate whether the reserved spot should be released. The spot would be retained only if the first message was batched and not sent immediately. The spot would be released when the batched message was pushed to the queue.
      - Test sending a batch with a 2-spots pending message queue, one spot for storing the batched message, another spot for preventing `ProducerQueueIsFull` error.
      - Test after all batched messages being sent, whether the reserved spots of producer's queue were  0.
      
      ### Verifying this change
      
      - [ ] Make sure that the change passes the CI checks.
      
      This change is already covered by existing tests, such as `BatchMessageTest.testSendCallback`, `BatchMessageTest.testPartitionedTopics` and `BasicEndToEndTest.testMessageTooBig`.
      5bb8809a
  11. 12 5月, 2020 2 次提交
    • M
      [C++] Subscription InitialPosition is not correctly set on regex consumers (#6810) · 0b803a83
      Matteo Merli 提交于
      ### Motivation
      
      The subscription `InitialPosition` is not currently set when using the multi-topic or regex consumers in C++/Python. 
      
      That makes that if you try to start from `MessageId::earliest`, it would be ignored.
      
      * [C++] Subscription InitialPosition is not correctly set on regex consumers
      
      * fix test fail for topic name
      
      * fix `make format`
      Co-authored-by: NJia Zhai <zhaijia@apache.org>
      0b803a83
    • Y
      Fix message id error if messages were sent to a partitioned topic (#6938) · 15cb920b
      Yunze Xu 提交于
      ### Motivation
      
      If messages were sent to a partitioned topic, the message id's `partition` field was always -1 because SendReceipt command only contains ledger id and entry id.
      
      ### Modifications
      
      - Add a `partition` field to `ProducerImpl` and set the `MessageId`'s `partition` field with it in `ackReceived` method later.
      - Add a test to check message id in send callback if messages were sent to a partitioned topic.
      15cb920b
  12. 25 4月, 2020 1 次提交
  13. 10 2月, 2020 1 次提交
  14. 07 2月, 2020 1 次提交
  15. 23 11月, 2019 1 次提交
  16. 06 11月, 2019 1 次提交
    • M
      Validate topic name before creating partition/non partition topic via admin cli. (#5148) · e0ea6b53
      Marvin Cai 提交于
      fix #4994
      For non partition topic,
      
      Topic name contains partition suffix "-partition-" and the remaining part follow the partition
      suffix is numeric value larger than the number of partition if there's already a partition topic with same
      name(the part before suffix "-partition-").
      2)Topic name contains partition suffix "-partition-" and the remaining part follow the partition
      suffix is numeric value but there isn't a partitioned topic with same name.
      For partition topic,
      Validation will fail and throw RestException if
      
      There's already a partitioned topic with same topic name and have some of its partition created.
      There's already non partition topic with same name and contains partition suffix "-partition-"
      followed by numeric value. In this case internal created partition of partitioned topic could override
      the existing non partition topic.
      This is for non partition topic created before we enforce the check as we will prevent creation of non partition topic with such name which could lost of confusion.
      For update partition topic,
      Validation will fail if there's already non partition topic with same name and contains partition suffix "-partition-" followed by numeric value X then the new number of partition of that partitioned topic can not be greater than that X else that non partition topic will essentially be overwritten and cause unexpected consequence.
      
      Also removed TopicsConsumerImplTest#testTopicAutoUpdatePartitions in flavor of PartitionedProducerConsumerTest#testAutoUpdatePartitionsForProducerConsumer, as they're both testing auto partition update to consumer/producer. But TopicsConsumerImplTest#testTopicAutoUpdatePartitions was trying to manually create non partitioned topic with name like "xyz-topic-partition-5" by creating new producer of that topic, while 5 is larger than a existing partitioned topic xyz-topic's actual number of partition. Which make the validation fails and shouldn't be encouraged.
      e0ea6b53
  17. 29 10月, 2019 1 次提交
  18. 25 10月, 2019 1 次提交
  19. 21 10月, 2019 1 次提交
  20. 10 10月, 2019 1 次提交
  21. 26 8月, 2019 1 次提交
    • J
      Add support in cpp client for 1 partitioned topic (#5016) · bf948909
      Jia Zhai 提交于
      ### Motivation
      
      IN PR #4883, we support 1 partitioned topic producer/consumer in java client. this is for Cpp client support.
      
      ### Modifications
      - change cpp client 
      - add unit test
      
      ### Verifying this change
      New added Ut Passed
      bf948909
  22. 05 8月, 2019 1 次提交
  23. 19 7月, 2019 1 次提交
    • [issue 4589] Fix redelivered message logic of partition topic (#4653) · cc5f25bf
      冉小龙 提交于
      Fixes #4589
      
      Motivation
      When using Partition-topic, the logic of redeliver messages will not be triggered when the time of ackTimeout arrives.
      
      This is because the unAckedMessageTrackerPtr_->add(msg.getMessageId()) is not call in the listener handling of partitioned topic in cpp code
      cc5f25bf
  24. 31 5月, 2019 1 次提交
  25. 29 5月, 2019 1 次提交
  26. 30 4月, 2019 1 次提交
    • E
      Revert dup consumer and related code (#4142) · 1e5b3dd9
      Ezequiel Lovelle 提交于
      * Revert "[cpp client] implement reference count for close() (#3863)"
      
      This reverts commit ee98e8b2.
      
      * Revert Prevent dup consumers and refCount for cpp client
      
      Revert "[cpp client] Bugfix prevent dup consumer for same topic subscription"
      Revert "[Issue #3226][cpp client] Prevent dup consumers on same client cnx"
      
      This reverts commit fff02e2a.
      This reverts commit 762e0ab9.
      
      * Revert "Feature - implement reference count for ConsumerImpl (#3795)"
      
      This reverts commit ff4db8db.
      
      * Revert Prevent dup consumers and refCount for java client
      
      Revert "Prevent dup consumers on same client cnx with shared subscription"
      Revert "[java client] Bugfix prevent dup consumers for same topic subscribe"
      
      This reverts commit 231db030.
      This reverts commit fb5dcd9a.
      1e5b3dd9
  27. 26 4月, 2019 1 次提交
    • N
      [Issue 2461][pulsar-client-cpp] Modified CMake files and source to enable... · b3596c41
      Nick Rivera 提交于
      [Issue 2461][pulsar-client-cpp] Modified CMake files and source to enable compilation on Windows (#4071)
      
      Fixes #2461
      
      ### Motivation
      
      
      My motivation was to be able to use the pulsar cpp client on Windows systems. 
      
      ### Modifications
      
      There are a number of modifications I needed to make to enable Windows compilation
      * Extensive rework of multiple CMakeLists.txt files
      * The creation of a PULSAR_PUBLIC define to define symbol visibility in lieue of #pragma GCC visibility push(default). This is because Windows requires specifying __declspec(dllexport) and __declspec(import) explicitly and does not have a #pragma GCC visibility push(default) analogue.
      * all calls to usleep or sleep have been replaced with calls to boost::this_thread::sleep()
      
      
      
      ### Verifying this change
      
      This change is a trivial rework / code cleanup without any test coverage. However, it does introduce a new platform to test on. It is likely that CI checks will have to be created. 
      b3596c41
  28. 27 3月, 2019 1 次提交
    • E
      [cpp client] implement reference count for close() (#3863) · ee98e8b2
      Ezequiel Lovelle 提交于
      Add reference count feature to keep track of reused instances of a consumer
      instance, for more details please see commit ff4db8db.
      
      *Modifications*
      
        - Add refCount instance variable on ConsumerImpl.
        - Use new safeDecrRefCount() on consumer close() in order to know whether
          effective close call should occur or not.
        - Increment reference count when a previous built consumer instance is being
          used by caller.
      
      *Future considerations*
      
      Thereafter when feature preventing duplicated consumer is made for
      PartitionedConsumer, MultiTopicsConsumer and PatternMultiTopicsConsumer,
      incrRefCount() member could be turned into a pure virtual method.
      ee98e8b2
  29. 25 3月, 2019 1 次提交
  30. 15 3月, 2019 1 次提交
  31. 14 3月, 2019 1 次提交
  32. 24 2月, 2019 2 次提交
  33. 08 2月, 2019 1 次提交
  34. 02 2月, 2019 1 次提交
    • M
      Replaced boost::bind with std::bind (#3484) · dd5d0519
      Matteo Merli 提交于
      * Replaced boost::bind with std::bind
      
      * Fixed merging with master
      
      * std::bind doesn't work with overloaded functions
      
      * Go back to asio thread to executor service
      
      * Use proper ref-count increase for WaitForCallback utility
      dd5d0519
  35. 31 1月, 2019 1 次提交
  36. 29 1月, 2019 1 次提交
  37. 27 1月, 2019 1 次提交
    • E
      [Issue #3226][cpp client] Prevent dup consumers on same client cnx (#3403) · 762e0ab9
      Ezequiel Lovelle 提交于
      Prevent same consumer subscription over the same client connection for cpp
      client. For more details please see explanation on commit 44e1a23.
      
      ### Motivation
      
      Fix #3226 for cpp client.
      
      ### Modifications
      
      Add check for `ClientImpl.cc` to know whether new shared consumer subscribe is already present
      on consumers vector or not.
      
      For further explanation please see #3312 
      
      ### Verifying this change
      
      This change added tests and can be verified as follows:
      
        - Add unit test asserting if duplicated consumers are allowed for shared
          subscription.
        - Add test preventing broker metadata error by closing a duplicate consumer
          over the same connection.
      762e0ab9
  38. 26 1月, 2019 1 次提交