Repository navigation
Closed
Description
Search before asking
- I searched in the issues and found nothing similar.
Version
- OS: Ubuntu 20.04
- Pulsar: 2.11.0
- C++ Client: main branch (05807bd)
Minimal reproduce step
#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?
- The 1st
createProducercall returnsResultConnectErrorbecause of the file descriptor limit. - The 2nd
createProducercall returnsResultOk.
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
rlimit.rlim_cur = 1;to
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?
- I'm willing to submit a PR!
Metadata
Metadata
Assignees
Labels
No labels
Activity
[fix] Handle exceptions when creating timers when fd limit is reached
[fix] Handle exceptions when creating timers when fd limit is reached
[fix] Handle exceptions when creating timers when fd limit is reached
[fix] Handle exceptions when creating timers when fd limit is reached (…