-
Notifications
You must be signed in to change notification settings - Fork 440
Compatibility with Phprdkafka 4.0 #959
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@Steveb-p What are the code changes required for handling this issue? Do you have any example? We are facing the same issue. Thanks in advanced. |
@anam-hossain #749 needs to be resolved. I've seen your response about |
4adef32
to
480bbea
Compare
@TiMESPLiNTER @makasim @nick-zh if you could take a look at this PR and see if I'm doing it alright. This should roughly replicate the current behavior for phprdkafka 3.x and wait for message delivery if there is no special configuration present ( There is still the "issue" of
|
|
||
// Compatibility with phprdkafka 4.0. | ||
if (isset($this->producer) && method_exists($this->producer, 'flush')) { | ||
$this->producer->flush($this->config['shutdown_timeout'] ?? -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe throw an error or log something if the return value is not RD_KAFKA_RESP_ERR_NO_ERROR
, sry not sure what the enqueue convention is for something like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As what we discussed: throwing an exception here would change the behavior and make it necessary for wrapping libraries (like enqueue-bundle) to catch it, so I've left it out.
However, I do agree that it is something that this package eventually should do, since otherwise potential delivery errors will be hidden from end user.
Issues we're steming from changes in image Dockerfile is based on (PHP version changed to 7.3) which caused phprdkafka extension to not be loaded and stubs were being used instead 😕 . I'd say we drop stubs loading in bootstrap.php in this situation? It's only really relevant when doing unit tests and it shouldn't really be that way - it makes those classes behave like phpunit's mocks :/ I've streamlined Dockerfile, spliting especially loading external OS dependencies for build and sorting them alphabetically. |
Except for the error handling, i think the changes do look ok. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to bump this PR and activate further development.
We have upgraded quite a big application to PHP 7.4. All our consumers are now stuck and can not be restarted when php-rdkafka:^3
is used.
bin/console messenger:consume --limit=1
So, after 1 message is processed, the process is "frozen" and does not return exit code 0.
There was no such an issue with PHP 7.3 + php-rdkafka 3.
Fortunately, upgrading to php-rdkafka
4 solves the issue.
I have forked enqueue/rdkafka
and installed the fork to the project - and it works as expected.
Questions: are you guys interested in merging this one? How can I help? Can we merge and release a new major version without waiting for #749 or should we continue to work with our fork?
Probably, as a compromise we can merge this one without tagging a major version, so that we can use dev-master
but not the fork.
PHP 7.3 works fine with php-rdkafka 3
PHP 7.4 does not work correctly with php-rdkafka 3
PHP 7.4 works fine with php-rdkafka 4
702c1a7
to
2fc820b
Compare
This allows compatibility with phprdkafka 4.0
2fc820b
to
b906e18
Compare
I've revisited the branch and removed all changes unrelated to actual compatibility with phprdkafka 4.0. Now all this does is introduce Other changes will be opened as separate PRs. |
@makasim are there any contributions needed to merge this? |
@makasim It should, I think it was working last time I've worked with it. But a lot of time has passed and I'm not sure - at the very least I'll need to take a look at it again. |
Looks good to me. |
$producer = new VendorProducer($this->getConf()); | ||
|
||
if (isset($this->config['log_level'])) { | ||
$producer->setLogLevel($this->config['log_level']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is setLogLevel
of RdKafka\Producer
be aware that it has been deprecated. Just having log_level
in RdKafka\Conf
is fine ✌️
@Steveb-p i do tend to forget which producer is which in enqueue, forgive me if my assumption is not correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nick-zh you're correct, this is directly calling setLogLevel
on Kafka Producer instance.
At this point I'm not really going to remove this deprecation, since in general PHP frameworks and applications should only log the deprecation (similarly to the default topic case). I'll address this in a separate PR.
@makasim I'd say it's good to go. There is a side effect of shutdown function being registered that mimics pre-4.0 kafka extension behavior, but I think it's... acceptable? For 3.0 versions it will be simply a no-op since |
Hi @Steveb-p, 👋 sorry for awaking this PR. Do you know what's the preferred value for Also, in general, do you have recommendations for low-latency Producer configuration? In the php-rdkafka docs I've found this: https://github.com/arnaud-lb/php-rdkafka#performance--low-latency-settings, but I'm wondering if there's more? What I had on mind was something like this:
I'm also wondering whether Thanks for all the great work you did here! 👍 |
Hey @nikolaposa These two links should help latency 1 and latency 2 from the c library. |
Thank you @nick-zh. 👍 Is |
No worries, yeah sry i forgot about this, seems it will flush when you call |
Thank you once again Nick, that's very useful to know. |
Hey. Looking at the rdkafka docs (https://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/rdkafka.flush.html) flush returns an
to
|
@see https://github.com/arnaud-lb/php-rdkafka/releases/tag/4.0.0
Since
poll
no longer gets called on destruct/shutdown, we should provide error handling (#749).I'm marking this as draft PR since otherwise we might have people losing messages when PHP process shuts down before message is acknowledged by Kafka broker.