-
-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve RD_KAFKA_RESP_ERR__TIMED_OUT to be able to differentiate cases #343
Comments
hey @moukoublen Sry i adjusted my answer i misunderstood. I am actually not sure, maybe it had something to do with differentiating eof and timeout. I would need to dig into this, but not sure if that is worth the while :D Cheers |
Hi I checked librdkafka examples rkm = rd_kafka_consumer_poll(rk, 100);
if (!rkm)
continue; /* Timeout: no message within 100ms,
* try again. This short timeout allows
* che and it seems to me that when the timeout passes without message That's why I am confused. 馃槙 EDIT: And how could we separate the timeout from php rdkafka which means no message arrived with a possible timeout coming actually from |
@moukoublen the differentiation right now is not possible, both will end in a timeout. So if the brokers recovers in a certain amount of time, you might not get an error at all, just timeouts. |
@nick-zh thanks for the answers so far 馃槃 So right now in php-rdkafka there is a differentiation from the default behavior of librdkafka In (librdkafka) But in php-rdkafka in case of null message pointer the /* ... php-rdkafka - kafka_consumer.c#L398 ... */
rkmessage = rd_kafka_consumer_poll(intern->rk, timeout_ms);
if (!rkmessage) {
rkmessage_tmp.err = RD_KAFKA_RESP_ERR__TIMED_OUT;
rkmessage = &rkmessage_tmp;
} By doing this -in php application level- we cannot separate an actual Wouldn't it be better if php-rdkafka returns another error code in this case? Or perhaps no error code at all - I don't know. What do you think? |
@moukoublen thanks for taking the time as well, i think this is a good discussion.
I am not really sure how we can achieve this, from what i see, when there is nothing to consume, librdkafka internally also sets timed out as last error: and the comment of the const is also rather general:
I am not that deep into the lib itself and i am unsure if both cases can be differentiatet properly, do you know that? Overall, when i see it from an application point of view, if i have a short timeout because of network, i probably |
@nick-zh yes, librdkafka does return the time out (in source code), but sample that @moukoublen linked (sample) is an implementation example that we - maybe - should follow. Since this causes difficulty in determining whether we have a broken connection or just no messages it would be in our interest to find a way to decide for ourselves 馃槃 |
I haven't found the code in librdkafka, where a broker connection issue results in |
@nick-zh @Steveb-p Correct me if I'm wrong here but to my understanding in librdkafka, when the poll operation finishes without message it sets the timeout error with And because of that So in normal scenario where "no message arrived during the timeout period" there is no message at all an no error code (apart from the global variable I understand what @nick-zh says. But my only concern is that: If there are not other scenarios where But if there are other scenarios where Thanks for your answers so far 馃槂 |
@moukoublen yeah i totally agree, the next thing with null is (i might be mistaken), the current behaviour returns NULL for eof as well (unless i set
I personally can live with the current state (since in the cases i have, i don't need to differentiate the timeouts, i will just keep polling in both cases), but if somebody wants to provide a PR to improve this, please do not hesitate! |
This fixes arnaud-lb#343 and fixes arnaud-lb#342. Allows for long-running scripts to continue consuming messages from broker, while not making user think that there is a connectivity error. In such case librdkafka will populate `err` property anyway.
This fixes arnaud-lb#343 and fixes arnaud-lb#342. Allows for long-running scripts to continue consuming messages from broker, while not making user think that there is a connectivity error. In such case librdkafka will populate `err` property anyway.
This fixes arnaud-lb#343 and fixes arnaud-lb#342. Allows for long-running scripts to continue consuming messages from broker, while not making user think that there is a connectivity error. In such case librdkafka will populate `err` property anyway.
I think we can use extern rd_kafka_resp_err_t RD_TLS rd_kafka_last_error_code;
static RD_UNUSED RD_INLINE
rd_kafka_resp_err_t rd_kafka_set_last_error (rd_kafka_resp_err_t err,
int errnox) {
if (errnox) {
/* MSVC:
* This is the correct way to set errno on Windows,
* but it is still pointless due to different errnos in
* in different runtimes:
* https://social.msdn.microsoft.com/Forums/vstudio/en-US/b4500c0d-1b69-40c7-9ef5-08da1025b5bf/setting-errno-from-within-a-dll?forum=vclanguage/
* errno is thus highly deprecated, and buggy, on Windows
* when using librdkafka as a dynamically loaded DLL. */
rd_set_errno(errnox);
}
rd_kafka_last_error_code = err;
return err;
} Since poll operation set error code to |
This fixes arnaud-lb#343 and fixes arnaud-lb#342. Allows for long-running scripts to continue consuming messages from broker, while not making user think that there is a connectivity error. In such case librdkafka will populate `err` property anyway.
Sorry for the late reply, so |
php-rdkafka/kafka_consumer.c
Line 398 in bad5cba
Hello,
This is a question mostly rather than an issue 馃槉
I'd like to ask why the default behavior of librdkafka (return null if no message appears during the specified timeout) has been replaced by returning the
RD_KAFKA_RESP_ERR__TIMED_OUT
error code.To my understanding having a null message (no message) after the specified timeout is not an error case. It is something expected isn't it?
Especially in cases where a small timeout is being used the application could have many
RD_KAFKA_RESP_ERR__TIMED_OUT
error code every minute.Could this "hide" a timeout error that could arrive from
rd_kafka_consumer_poll
pointing out actual timeout during broker communication?Thanks鈽猴笍
The text was updated successfully, but these errors were encountered: