php-rdkafka: Exception during producer shutdown since 4.0.3 (race condition, RdKafka\Kafka::__construct() has not been called)
A few days ago, I added kafka to my project, and deployed in product env, and some error logs occurred (log in below).
I’m not sure this fault caused by rdkafka, but it doesn’t happen before. If i remove the kafka code, the error disappeared. I’d write a simple test script, but doesn’t reproduce the same error.
Can someone help me to find the real reason. Thanks.
- PHP version: 7.2.31
- librdkafka version: 1.4.0
- php-rdkafka version: 4.0.3
- kafka version: kafka_2.12-2.4.1
[17-May-2020 10:50:49] WARNING: [pool www] child 17854 said into stderr: "NOTICE: PHP message: PHP Fatal error: Uncaught Exception: RdKafka\Kafka::__construct() has not been called in [no active file]:0"
[17-May-2020 10:50:49] WARNING: [pool www] child 17854 said into stderr: "Stack trace:"
[17-May-2020 10:50:49] WARNING: [pool www] child 17854 said into stderr: "#0 {main}"
[17-May-2020 10:50:49] WARNING: [pool www] child 17854 said into stderr: " thrown in [no active file] on line 0"
[17-May-2020 10:50:49] WARNING: [pool www] child 17854 said into stderr: "[no active file](0) : Fatal error - Uncaught Exception: RdKafka\Kafka::__construct() has not been called in [no active file]:0"
[17-May-2020 10:50:49] WARNING: [pool www] child 17854 said into stderr: "Stack trace:"
[17-May-2020 10:50:49] WARNING: [pool www] child 17854 said into stderr: "#0 {main}"
[17-May-2020 10:50:49] WARNING: [pool www] child 17854 said into stderr: " thrown"
[17-May-2020 10:50:49] WARNING: [pool www] child 17854 said into stderr: "/home/www/softwares/php-7.2.31/ext/opcache/ZendAccelerator.c:652: accel_rep
lace_string_by_process_permanent: Assertion `!((char*)(str) >= (accel_shared_globals->interned_strings_start) && (char*)(str) < (accel_shared_globals
->interned_strings_end))' failed."
[17-May-2020 10:50:50] WARNING: [pool www] child 17854 exited on signal 6 (SIGABRT - core dumped) after 2750.439072 seconds from start
[17-May-2020 10:50:50] NOTICE: [pool www] child 25102 started
#0 0x00007f296baf72c7 in raise () from /lib64/libc.so.6
#1 0x00007f296baf89b8 in abort () from /lib64/libc.so.6
#2 0x00007f296baf00e6 in __assert_fail_base () from /lib64/libc.so.6
#3 0x00007f296baf0192 in __assert_fail () from /lib64/libc.so.6
#4 0x00007f2969753f1b in accel_replace_string_by_process_permanent (str=0x7f295c78d8b0)
at /home/www/softwares/php-7.2.31/ext/opcache/ZendAccelerator.c:652
#5 0x00007f2969753606 in accel_copy_permanent_strings (new_interned_string=0x7f2969753e49 <accel_replace_string_by_process_permanent>)
at /home/www/softwares/php-7.2.31/ext/opcache/ZendAccelerator.c:528
#6 0x00007f2969753fee in accel_use_permanent_interned_strings () at /home/www/softwares/php-7.2.31/ext/opcache/ZendAccelerator.c:679
#7 0x00007f2969759194 in accel_shutdown () at /home/www/softwares/php-7.2.31/ext/opcache/ZendAccelerator.c:2874
#8 0x00007f296975b878 in zm_shutdown_zend_accelerator (type=1, module_number=43)
at /home/www/softwares/php-7.2.31/ext/opcache/zend_accelerator_module.c:435
#9 0x0000000000a38858 in module_destructor (module=0x2180080) at /home/www/softwares/php-7.2.31/Zend/zend_API.c:2564
#10 0x0000000000a2c976 in module_destructor_zval (zv=0x7ffdbe856890) at /home/www/softwares/php-7.2.31/Zend/zend.c:690
#11 0x0000000000a42b7e in _zend_hash_del_el_ex (ht=0x1682100 <module_registry>, idx=42, p=0x1fd0520, prev=0x0)
at /home/www/softwares/php-7.2.31/Zend/zend_hash.c:998
#12 0x0000000000a42c49 in _zend_hash_del_el (ht=0x1682100 <module_registry>, idx=42, p=0x1fd0520)
at /home/www/softwares/php-7.2.31/Zend/zend_hash.c:1021
#13 0x0000000000a441a2 in zend_hash_graceful_reverse_destroy (ht=0x1682100 <module_registry>)
at /home/www/softwares/php-7.2.31/Zend/zend_hash.c:1477
#14 0x0000000000a36647 in zend_destroy_modules () at /home/www/softwares/php-7.2.31/Zend/zend_API.c:2008
#15 0x0000000000a2ce7a in zend_shutdown () at /home/www/softwares/php-7.2.31/Zend/zend.c:905
#16 0x000000000099bac4 in php_module_shutdown () at /home/www/softwares/php-7.2.31/main/main.c:2458
#17 0x0000000000b26f8d in main (argc=1, argv=0x7ffdbe856db8) at /home/www/softwares/php-7.2.31/sapi/fpm/fpm/fpm_main.c:2020
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (1 by maintainers)
I added a log, then the log and Fatal error occurred at the same time.
Then I modified the topi.c:
The Fatal error disappeared.
I think it’s resolved the problem. Thanks.
@nick-zh Thanks very much. I will do more testing, if I find some more information, I will tell . Maybe my script is too complicated.
@Steveb-p No, I use php singleton pattern , and the script call the producer only once, and exit.