BewareMyPower opened a new pull request, #203: URL: https://github.com/apache/pulsar-client-cpp/pull/203
Fixes #202 ### Motivation When a `deadline_timer` is constructed, `boost::system::system_error` would be thrown if the fd limit is reached. In this case, the following APIs would fail with exception instead of returning a `Result`: - `createProducer` - `subscribe` - `createReader` P.S. This behavior is not documented in Boost's documents. Generally, we should not allow exceptions being thrown from those APIs because we return a `Result` to indicate the error. In addition, these exceptions cannot be caught by the wrapper of other languages. There is a similar issue: https://github.com/apache/pulsar/issues/14582. However, https://github.com/apache/pulsar/pull/14587 only fixes the case when creating a `socket`. The exception from the constructor of `deadline_timer` is not processed. ### Modifications Handle the exceptions when creating a socket or timer from `ExecutorService` to restart this executor, then propagate a `std::runtime_error`. Don't allow creating a timer directly from `io_service` so that exceptions can be handled well. In addition, catch the `runtime_error` when: - Creating a producer (`ProducerImpl` and `PartitionedProducerImpl`) - Creating a consumer (`ConsumerImpl` and `MultiTopicsConsumerImpl`) - Creating a reader (`ReaderImpl`) because the constructors of them all create at least one timer. ### Verifications Add `tests/unix/ConnectionFailTest.cc` for Unix systems because `setrlimit` is a POSIX API. It covers the cases when the fd limit is not enough to create a producer, a consumer and a reader. ### Documentation <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> - [ ] `doc-required` (Your PR needs to update docs and you will update later) - [x] `doc-not-needed` (Please explain why) - [ ] `doc` (Your PR contains doc changes) - [ ] `doc-complete` (Docs have been already added) -- 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]
