You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "BewareMyPower (via GitHub)" <gi...@apache.org> on 2023/02/20 10:05:06 UTC
[GitHub] [pulsar-client-cpp] BewareMyPower opened a new issue, #202: [Bug] Exception could be thrown when creating producers or consumers
BewareMyPower opened a new issue, #202:
URL: https://github.com/apache/pulsar-client-cpp/issues/202
### Search before asking
- [X] I searched in the [issues](https://github.com/apache/pulsar-client-cpp/issues) and found nothing similar.
### Version
- OS: Ubuntu 20.04
- Pulsar: 2.11.0
- C++ Client: main branch (05807bdaf3a4341b22efd7c71f7b00c47cc31413)
### Minimal reproduce step
```c++
#include <errno.h>
#include <pulsar/Client.h>
#include <string.h>
#include <sys/resource.h>
using namespace pulsar;
int main() {
struct rlimit oldLimit;
if (getrlimit(RLIMIT_NOFILE, &oldLimit) < 0) {
std::cerr << "Failed to get rlimit: " << strerror(errno) << std::endl;
return 1;
}
std::cout << "original limit: " << oldLimit.rlim_cur << " " << oldLimit.rlim_max << std::endl;
struct rlimit rlimit;
rlimit.rlim_cur = 1;
rlimit.rlim_max = oldLimit.rlim_max;
if (setrlimit(RLIMIT_NOFILE, &rlimit) < 0) {
std::cerr << "Failed to set rlimit: " << strerror(errno) << std::endl;
return 1;
}
Client client("pulsar://localhost:6650");
Producer producer;
auto result = client.createProducer("my-topic", producer);
if (result != ResultOk) {
std::cerr << "Failed to create producer " << result << ", try to reset the RLIMIT_NOFILE"
<< std::endl;
}
if (setrlimit(RLIMIT_NOFILE, &oldLimit) < 0) {
std::cerr << "Failed to set rlimit: " << strerror(errno) << std::endl;
return 1;
}
result = client.createProducer("my-topic", producer);
if (result != ResultOk) {
std::cerr << "Failed to create producer " << result << std::endl;
return 2;
}
client.close();
}
```
### What did you expect to see?
1. The 1st `createProducer` call returns `ResultConnectError` because of the file descriptor limit.
2. The 2nd `createProducer` call returns `ResultOk`.
### What did you see instead?
```
2023-02-20 10:02:41.489 ERROR [140184068893696] ClientConnection:186 | Failed to initialize connection: eventfd_select_interrupter: Too many open files [system:24]
2023-02-20 10:02:41.489 INFO [140184068893696] ClientConnection:1650 | [<none> -> pulsar://localhost:6650] Connection disconnected
2023-02-20 10:02:41.489 INFO [140184068893696] ConnectionPool:97 | Created connection for pulsar://localhost:6650
2023-02-20 10:02:41.489 INFO [140184068893696] ClientConnection:270 | [<none> -> pulsar://localhost:6650] Destroyed connection
terminate called after throwing an instance of 'boost::wrapexcept<boost::system::system_error>'
what(): eventfd_select_interrupter: Too many open files [system:24]
Aborted
```
### Anything else?
If we increased the limit from 1 to 5, i.e. changed
```c++
rlimit.rlim_cur = 1;
```
to
```c++
rlimit.rlim_cur = 5;
```
then it would work as expected:
```
original limit: 1024 1048576
2023-02-20 10:04:54.863 INFO [140200259120128] ClientConnection:191 | [<none> -> pulsar://localhost:6650] Create ClientConnection, timeout=10000
2023-02-20 10:04:54.863 INFO [140200259120128] ConnectionPool:97 | Created connection for pulsar://localhost:6650
2023-02-20 10:04:54.864 ERROR [140200259073792] ClientConnection:564 | [<none> -> pulsar://localhost:6650] Resolve error: asio.netdb:1 : Host not found (authoritative)
2023-02-20 10:04:54.865 ERROR [140200259073792] ClientConnection:1648 | [<none> -> pulsar://localhost:6650] Connection closed with ConnectError
2023-02-20 10:04:54.865 ERROR [140200259073792] ClientImpl:201 | Error Checking/Getting Partition Metadata while creating producer on persistent://public/default/my-topic -- ConnectError
Failed to create producer ConnectError, try to reset the RLIMIT_NOFILE
2023-02-20 10:04:54.865 INFO [140200259073792] ClientConnection:270 | [<none> -> pulsar://localhost:6650] Destroyed connection
2023-02-20 10:04:54.865 INFO [140200259120128] ConnectionPool:86 | Deleting stale connection from pool for pulsar://localhost:6650 use_count: -1 @ 0
2023-02-20 10:04:54.865 INFO [140200259120128] ClientConnection:191 | [<none> -> pulsar://localhost:6650] Create ClientConnection, timeout=10000
2023-02-20 10:04:54.865 INFO [140200259120128] ConnectionPool:97 | Created connection for pulsar://localhost:6650
2023-02-20 10:04:54.867 WARN [140200259073792] ClientConnection:457 | [<none> -> pulsar://localhost:6650] Failed to establish connection: Connection refused
2023-02-20 10:04:54.868 INFO [140200259073792] ClientConnection:389 | [127.0.0.1:34564 -> 127.0.0.1:6650] Connected to broker
2023-02-20 10:04:54.873 INFO [140200259073792] HandlerBase:72 | [persistent://public/default/my-topic-partition-0, ] Getting connection from pool
2023-02-20 10:04:54.876 INFO [140200259073792] ProducerImpl:205 | [persistent://public/default/my-topic-partition-0, ] Created producer on broker [127.0.0.1:34564 -> 127.0.0.1:6650]
2023-02-20 10:04:54.876 INFO [140200259120128] ClientImpl:529 | Closing Pulsar client with 1 producers and 0 consumers
2023-02-20 10:04:54.877 INFO [140200259120128] ProducerImpl:745 | [persistent://public/default/my-topic-partition-0, standalone-100-13] Closing producer for topic persistent://public/default/my-topic-partition-0
2023-02-20 10:04:54.878 INFO [140200259073792] ProducerImpl:709 | [persistent://public/default/my-topic-partition-0, standalone-100-13] Closed producer 0
2023-02-20 10:04:54.879 ERROR [140200259073792] ClientConnection:835 | [127.0.0.1:34564 -> 127.0.0.1:6650] Connection already disconnected
2023-02-20 10:04:54.879 INFO [140200233862912] ClientConnection:1650 | [127.0.0.1:34564 -> 127.0.0.1:6650] Connection disconnected
2023-02-20 10:04:55.379 INFO [140200259120128] ProducerImpl:699 | Producer - [persistent://public/default/my-topic-partition-0, standalone-100-13] , [batchMessageContainer = { BatchMessageContainer [size = 0] [bytes = 0] [maxSize = 1000] [maxBytes = 131072] [topicName = persistent://public/default/my-topic-partition-0] [numberOfBatchesSent_ = 1] [averageBatchSize_ = 0] }]
2023-02-20 10:04:55.379 INFO [140200259120128] ClientConnection:270 | [127.0.0.1:34564 -> 127.0.0.1:6650] Destroyed connection
```
### Are you willing to submit a PR?
- [X] I'm willing to submit a PR!
--
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: commits-unsubscribe@pulsar.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-cpp] shibd closed issue #202: [Bug] Exception could be thrown when creating producers or consumers
Posted by "shibd (via GitHub)" <gi...@apache.org>.
shibd closed issue #202: [Bug] Exception could be thrown when creating producers or consumers
URL: https://github.com/apache/pulsar-client-cpp/issues/202
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org