From 3581f120a4b63b24fc8ebabc88db867be4dc4a80 Mon Sep 17 00:00:00 2001 From: Jake Moilanen Date: Fri, 15 Aug 2014 09:53:01 -0500 Subject: [PATCH 1/2] Don't send all messages to partition 0. Most kafka instances have multiple partitions and need to spread them across all partitions for best performance --- library.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.c b/library.c index 94191e6..ad8a94e 100644 --- a/library.c +++ b/library.c @@ -86,7 +86,7 @@ void kafka_produce(char* topic, char* msg, int msg_len) signal(SIGPIPE, kafka_stop); rd_kafka_topic_t *rkt; - int partition = 0; + int partition = RD_KAFKA_PARTITION_UA; /* Create topic */ rkt = rd_kafka_topic_new(rk, topic, NULL); From 327dd956f35a8587c3f5266c58e5a30c48f2b251 Mon Sep 17 00:00:00 2001 From: Jake Moilanen Date: Tue, 2 Dec 2014 16:43:06 -0600 Subject: [PATCH 2/2] Remove the kafka_stop call on error, as "errors" come in for recoverable situations like a broker in a pool not being able to be connected to. Calling kafka_stop() causes memory to be freed downstream which then causes segfaults --- library.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/library.c b/library.c index ad8a94e..598bdfd 100644 --- a/library.c +++ b/library.c @@ -25,8 +25,6 @@ void kafka_err_cb (rd_kafka_t *rk, int err, const char *reason, void *opaque) { openlog("phpkafka", 0, LOG_USER); syslog(LOG_INFO, "phpkafka - ERROR CALLBACK: %s: %s: %s\n", rd_kafka_name(rk), rd_kafka_err2str(err), reason); - - kafka_stop(err); } void kafka_msg_delivered (rd_kafka_t *rk,