Skip to content
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

RHEL 8 OS family error creating kafka handle and thread #4966

Closed
JPvRiel opened this issue Aug 19, 2022 · 29 comments
Closed

RHEL 8 OS family error creating kafka handle and thread #4966

JPvRiel opened this issue Aug 19, 2022 · 29 comments

Comments

@JPvRiel
Copy link

JPvRiel commented Aug 19, 2022

Expected behavior

Kafka modules load.

Actual behavior

Kafka modules fail to create threads.

rsyslogd: imkafka: error creating kafka handle: Failed to create thread: No such file or directory (2)  [v8.2208.0 try https://www.rsyslog.com/e/2422 ]
rsyslogd: activation of module imkafka failed [v8.2208.0 try https://www.rsyslog.com/e/2422 ]
rsyslogd: omkafka: error creating kafka handle: Failed to create thread: Success (0)  [v8.2208.0 try https://www.rsyslog.com/e/2422 ]

Sometimes there's a crash as well: "Segmentation fault (core dumped) rsyslogd -n"

Steps to reproduce the behavior

Simplified e.g. of our production issue.

Cut and paste RPM-GPG-KEY-Adiscon key from: https://www.rsyslog.com/rhelcentos-rpms/. Downloading from http://rpms.adiscon.com is not secure.

Dockerfile:

FROM almalinux:8
ENV container=docker
COPY RPM-GPG-KEY-Adiscon /etc/pki/rpm-gpg/RPM-GPG-KEY-Adiscon
ADD http://rpms.adiscon.com/v8-stable/rsyslog.repo /etc/yum.repos.d/rsyslog.repo
ARG RSYSLOG_VERSION='8.2208.0'
RUN dnf --setopt=tsflags=nodocs -y install \
  rsyslog-${RSYSLOG_VERSION} \
  rsyslog-kafka-${RSYSLOG_VERSION}
RUN rm -rf /etc/rsyslog.d/ \
  && rm -f /etc/rsyslog.conf
COPY rsyslog.conf /etc/rsyslog.conf
EXPOSE 514/udp
ENV RSYSLOG_DEBUG="Debug LogFuncFlow FileTrace=imkafka.c"
CMD bash -c 'rsyslogd -n'

rsyslog.conf

global(workDirectory="/var/lib/rsyslog")

module(load="imudp")
module(load="omkafka")
module(load="imkafka")

input(type="imudp" port="514")
input(type="imkafka" topic="debug-out" broker=["localhost:9092"])

action(type="omkafka" topic="debug-out" broker=["localhost:9092"])

Build and run:

docker build -t jpvriel/rsyslog:debug .
docker run --rm jpvriel/rsyslog:debug

Output:

...
9425.785176414:main thread    : rainerscript.c: load:  'imkafka'
9425.785191712:main thread    : modules.c: Requested to load module 'imkafka'
9425.785199629:main thread    : modules.c: loading module '/usr/lib64/rsyslog/imkafka.so'
9425.785528504:main thread    : imkafka.c: imkafka 8.2208.0 using librdkafka version 0.11.6, 0xb06ff
9425.785541581:main thread    : modules.c: module imkafka of type 0 being loaded (keepType=0).
9425.785550864:main thread    : modules.c: module config name is 'imkafka'
9425.785557106:main thread    : modules.c: module imkafka supports rsyslog v6 config interface
9425.785567276:main thread    : imkafka.c: entry point 'doHUP' not present in module
9425.785575326:main thread    : imkafka.c: module (global) param blk for imkafka:
...
9425.786056224:main thread    : rainerscript.c: type:  'imkafka'
9425.786071810:main thread    : imkafka.c: newInpInst (imkafka)
9425.786078880:main thread    : rainerscript.c: nvlstGetParam: name 'topic', type 14, valnode->bUsed 0
9425.786088699:main thread    : rainerscript.c: nvlstGetParam: name 'broker', type 15, valnode->bUsed 0
9425.786098173:main thread    : imkafka.c: input param blk in imkafka:
9425.786106052:main thread    : rainerscript.c: topic:  'debug-out'
9425.786120805:main thread    : rainerscript.c: broker: ARRAY:
9425.786130511:main thread    : rainerscript.c:   string 'localhost:9092'
9425.786144880:main thread    : rainerscript.c: 
9425.786150600:main thread    : rainerscript.c: confparam: (unset)
9425.786164380:main thread    : rainerscript.c: consumergroup: (unset)
9425.786178240:main thread    : rainerscript.c: ruleset: (unset)
9425.786191921:main thread    : rainerscript.c: parsehostname: (unset)
9425.786207526:main thread    : imkafka.c: imkafka: newInpIns brokers=localhost:9092, topic=debug-out, consumergroup=(null)
...
9425.787434782:main thread    : rsconf.c: beginCnfLoad(0x7f5b4b067d70) for module 'imkafka'
...
9425.787479202:main thread    : rsconf.c: module imkafka tells us config can be activated
...
9425.791498239:main thread    : rsconf.c: pre priv drop activating config 0x563b14c28de0 for module imkafka
...
9425.791590024:main thread    : rsconf.c: activating config 0x563b14c28de0 for module imkafka
9425.797895222:main thread    : errmsg.c: Called LogMsg, msg: imkafka: error creating kafka handle: Failed to create thread: No such file or directory (2)

Debug options

I clearly misunderstood the docs (<https://www.rsyslog.com/doc/master/troubleshooting/debug.html) because function tracing debug options didn't apply given ENV RSYSLOG_DEBUG='Debug LogFuncFlow FileTrace=imkafka.c':

rsyslogd 8.2208.0 error: invalid debug option 'LogFuncFlow' - ignored
rsyslogd 8.2208.0 error: invalid debug option 'FileTrace=imkafka.c' - ignored

Environment

  • rsyslog version: v8.2208.0
  • platform: AlmaLinux 8.6

Related:

Use-case

Trying to update my containerized rsyslog solution https://github.com/JPvRiel/docker-rsyslog from the out of date CentOS 7 base towards newer alternatives like AlmaLinux 8 which is binary compatible with RHEL 8, and not a beta channel like CentoOS 8.

@JPvRiel
Copy link
Author

JPvRiel commented Aug 19, 2022

Just tried this on RockyLinux too. Same error.

FROM rockylinux:8
ENV container=docker
COPY RPM-GPG-KEY-Adiscon /etc/pki/rpm-gpg/RPM-GPG-KEY-Adiscon
ADD http://rpms.adiscon.com/v8-stable/rsyslog.repo /etc/yum.repos.d/rsyslog.repo
ARG RSYSLOG_VERSION='8.2208.0'
RUN dnf --setopt=tsflags=nodocs -y install \
  rsyslog-${RSYSLOG_VERSION} \
  rsyslog-kafka-${RSYSLOG_VERSION}
RUN rm -rf /etc/rsyslog.d/ \
  && rm -f /etc/rsyslog.conf
COPY rsyslog.conf /etc/rsyslog.conf
EXPOSE 514/udp
ENV RSYSLOG_DEBUG='Debug LogFuncFlow FileTrace=imkafka.c'
CMD bash -c 'rsyslogd -n'

@JPvRiel
Copy link
Author

JPvRiel commented Aug 20, 2022

Just did a test with Ubuntu 22.04 and it does not have this issue. Same config. Suggests the issue is platform specific. Maybe rsyslog has an oldere version of librdkafka statically built in that has this RHEL OS family bug for lirdkafka: confluentinc/librdkafka#2681

See https://github.com/JPvRiel/docker-rsyslog/tree/master/debug/imkafka_load for roughly testing this issue on multiple distros.

@JPvRiel JPvRiel changed the title RHEL/AlmaLinux 8 error creating kafka handle and thread RHEL 8 OS family error creating kafka handle and thread Aug 21, 2022
@alorbach
Copy link
Member

That issue is actually a combination of the version of GLIBC and librdkafka, which we use to build our packages on:
confluentinc/librdkafka#2681

It has been fixed by this commit:
confluentinc/librdkafka@7915f2a

@rgerhards: We will need to update the librdkafa version used by our build system in order to fix this problem.

@rgerhards
Copy link
Member

We will need to update the librdkafa version used by our build system in order to fix this problem.

This sounds like we need to resort (again) to providing a statically-linked librdkafka. This is definitely not my favorite move. Any ways around?

@alorbach
Copy link
Member

We will need to update the librdkafa version used by our build system in order to fix this problem.

This sounds like we need to resort (again) to providing a statically-linked librdkafka. This is definitely not my favorite move. Any ways around?

We chose to use our own static version of librdkafka because of issues with older library versions on older distrbutions.
So I think we will need to update kafka static packages again.

@rgerhards
Copy link
Member

We chose to use our own static version of librdkafka because of issues with older library versions on older distrbutions.
So I think we will need to update kafka static packages again.

As far as I know, and hope, we do not use the static version for at least 2 yrs now - at least that was communicated. I find it always ugly to work with static libraries, as this means we take over responsibility for timely applying patches to these libraries and that in turn means we need to monitor activity closely. I really don't like that idea and was happy we could drop it (I hope we actually did...).

@alorbach
Copy link
Member

We can schedule periodic builds for our static librdkafka packages based on current librdkafka release. Or we can try to switch back to system build packages of librdkafka which could be even older on RHEL plattforms.

@rgerhards
Copy link
Member

Or we can try to switch back to system build packages of librdkafka which could be even older on RHEL plattforms.

As far as I know, we have done so already. Didn't we do?

@rgerhards
Copy link
Member

Side-note: as far as I remember, librdkafka made changes that broke our static build. We used a crude work-around, (some type of patch, which could not applied automatically) but that also had some problems. Then, we saw that the version advanced sufficiently so that we could simply use distro packages and ditch building our own static lib. At least this is what I think happened. Maybe we used an old version for some time because we had no better idea. Ugly, ugly, ugly, ...

@alorbach
Copy link
Member

Or we can try to switch back to system build packages of librdkafka which could be even older on RHEL plattforms.

As far as I know, we have done so already. Didn't we do?

The RHEL packages build on static for sure. This might be different for the Ubuntu / Debian packages.

@JPvRiel
Copy link
Author

JPvRiel commented Aug 23, 2022

The RHEL packages build on static for sure.

What I noticed when installing kafka via the rsyslog adiscon repo, e.g. dnf install rsyslog-kafka-8.2208.0, there is a maybe dependency to install adisconbuild-librdkafka1-0.11.6. I suspect you guys did this to workaround the issue on RHEL where distro librdkafka packages were too far out of date? So it's not static, but your own dynamic lib you have in your repo? However, your repo version (0.11.6?) got too far behind and is now not plyaing nice with RHEL8 glibc?

Upstream has released 1.9.2? While 0.11.6 is very old - dated 18 Oct 2018.

@alorbach
Copy link
Member

alorbach commented Aug 24, 2022

@JPvRiel It was a workaround back then needed to build packages for REHL and was not reviewed for updates since it was working until now. I will look into this and have our librdkafka updated as soon as possible.

@rgerhards
Copy link
Member

@alorbach this thread, BTW, nicely shows what is wrong with providing librdkafka, even if it may be necessary.

That said, @JPvRiel which version of librdkafka is your distro default? I think I remember that we had found out "regular" versions were new enough - espicially as we used (and seem to still use on CentOS) veeeeeery old versions.

@alorbach When we link statically, we should NOT provide any kafaka package to the end user. After all, static linking means that the library code is inside the rsyslog plugin. If we ship kafka libs, we may mess up with the end user's system. Even though this seems not to be too bad, as we never heard a complaint.

@alorbach
Copy link
Member

@rgerhards: the good news is that we infact do not provide any kafka libaries on the users end system. Infact the adisconbuild-librdkafka-devel is only required and installed at buildtime inside mock containers.

Btw, redhad provides even older version for EHEL 7 / 8 ;)
https://rpms.remirepo.net/rpmphp/zoom.php?rpm=librdkafka

@rgerhards
Copy link
Member

Infact the adisconbuild-librdkafka-devel is only required and installed at buildtime inside mock containers.

That sounded different from @JPvRiel "What I noticed when installing kafka via the rsyslog adiscon repo, e.g. dnf install rsyslog-kafka-8.2208.0, there is a maybe dependency to install adisconbuild-librdkafka1-0.11.6."

@alorbach
Copy link
Member

Infact the adisconbuild-librdkafka-devel is only required and installed at buildtime inside mock containers.

That sounded different from @JPvRiel "What I noticed when installing kafka via the rsyslog adiscon repo, e.g. dnf install rsyslog-kafka-8.2208.0, there is a maybe dependency to install adisconbuild-librdkafka1-0.11.6."

I double checked the rsyslog specfile, there is only a "BuildRequires" dependency for adisconbuild-librdkafka.

@rgerhards
Copy link
Member

strange

@alorbach
Copy link
Member

Anyway I am building devel packages for librdkafka 1.9.2 at the moment, everything looks fine so far.
Tomorrow we will see if the nightly rpm packages were build. If everything goes fine, we can update the current v8-stable packages.

@alorbach
Copy link
Member

Daily packages have been build with new librdkafka finally:
http://rpms.adiscon.com/v8-stable-daily/rsyslog-daily.repo

For all distributions epel7-9 and rhel7-9.
However there seem some compatiblity issues with changed / missing API symbols now. I will continue this on monday.

@JPvRiel
Copy link
Author

JPvRiel commented Aug 28, 2022

That said, @JPvRiel which version of librdkafka is your distro default? I think I remember that we had found out "regular" versions were new enough - espicially as we used (and seem to still use on CentOS) veeeeeery old versions.

@rgerhards, thought it might interest you to see a review of which versions get packaged. I've been wanting to upgrade my container base from CentOS7 to RedHat/Alma Linux 8, but as I understand it, the conflict with the statically linked librdkafka bug in the rsyslog-kafka rpm package blocks it.

Maybe for RedHat 7x, the distro librdkafka version was too old. In RedHat family 8.x, 0.11.4 < 0.11.6, where 0.11.6 is the version supplied by adisconbuild-librdkafka that is pulled in by rsyslog-kafka. But this is maybe misleading in that if rsyslog-kafka statically includes it's own version of librdkafka? So adisconbuild-librdkafka is superfluous and has no effect? E.g. it's adding a dynamic lib that rsyslog-kafka no longer uses?

I checked by quickly spooling up a few containers. CentOS8 and RedHat UBI images don't play well and don't seem to have librdkafka available in repos. UBI is supposed to be RedHat's offical free-to-use container bases, but the repos they use seem very limited. Rocky/Alma Linux are the two leading RHEL binary compatible distros that seem the most popular successors to CentOS. Seems librdkafka version remains quite out of date in the RHEL 8 family, but got a bump with RHEL 9. However, debian/Ubuntu universe repo on average seems to keep better pace with upstream releases. By the way, I also checked Alpine, and there is a librdkafka package for it now - related to rsyslog/rsyslog-docker#6?

OS librdkafka
CentOS 7.9.2009 0.11.4-1
CentOS 8.4.2105 N/A
Rocky 8.6 0.11.4-3
Redhat-UBI 8 N/A
Rocky 9.0 1.6.1-102
Alma 9.0 1.6.1-102
Ubuntu 18.04.6 0.11.3-1
Ubuntu 20.04.4 1.2.1-1
Ubuntu 22.04.1 1.8.0-1
Alpine 3.16 1.8.2-r0

E.g.: CentOS 7:

docker run --rm centos:7 bash -c 'yum makecache && yum -y install librdkafka'

 Installing : librdkafka-0.11.4-1.el7.x86_64

E.g. Redhat UBI 8 and CentoOS 8 has no package available:

docker run --rm registry.access.redhat.com/ubi8/ubi-minimal bash -c 'microdnf makecache && microdnf -y install librdkafka'

error: No package matches 'librdkafka'

E.g. Ubuntu/Debian community tracks upstream releases better:

docker run --rm ubuntu:20.04 bash -c 'apt update && apt -y install librdkafka1'

Setting up librdkafka1:amd64 (1.2.1-1ubuntu1) ...

@rgerhards
Copy link
Member

In RedHat family 8.x, 0.11.4 < 0.11.6, where 0.11.6 is the version supplied by adisconbuild-librdkafka that is pulled in by rsyslog-kafka. But this is maybe misleading in that if rsyslog-kafka statically includes it's own version of librdkafka? So adisconbuild-librdkafka is superfluous and has no effect? E.g. it's adding a dynamic lib that rsyslog-kafka no longer uses?

@alorbach can you comment? I would really like to get that issue straight.

@alorbach
Copy link
Member

alorbach commented Sep 6, 2022

In RedHat family 8.x, 0.11.4 < 0.11.6, where 0.11.6 is the version supplied by adisconbuild-librdkafka that is pulled in by rsyslog-kafka. But this is maybe misleading in that if rsyslog-kafka statically includes it's own version of librdkafka? So adisconbuild-librdkafka is superfluous and has no effect? E.g. it's adding a dynamic lib that rsyslog-kafka no longer uses?

@alorbach can you comment? I would really like to get that issue straight.

I am sorry I missed that notification. adisconbuild-librdkafka is not superfluous. The package is needed only at BUILD time for the machine building the packages, in order to include the librdkafka version from that package statically into omkafka / imkafka modules.

@alorbach
Copy link
Member

alorbach commented Sep 6, 2022

Anyway the daily packages have been build with librdkafka 1.9.2 now, but there seems to be another issue now:

rsyslogd: could not load module 'omkafka', errors: trying to load module /usr/lib64/rsyslog/omkafka.so: /usr/lib64/rsyslog/omkafka.so: undefined symbol: rd_kafka_purge [v8.2210.0.master try https://www.rsyslog.com/e/2066 ]
rsyslogd: could not load module 'imkafka', errors: trying to load module /usr/lib64/rsyslog/imkafka.so: /usr/lib64/rsyslog/imkafka.so: undefined symbol: rd_kafka_message_errstr [v8.2210.0.master try https://www.rsyslog.com/e/2066 ]

I am looking into this at the moment.

@JPvRiel
Copy link
Author

JPvRiel commented Nov 3, 2022

@alorbach , thanks for the efforts so far! Just a heads up that 8.2210.0 now fails on both RHEL 7.x and 8.x bases. Previously, 8.2208.0 could not work with RHEL 8.x, but at least it worked with RHEL 7.x, though librdkafka was old? I think though, it's better to fail forward and push / get into the issue fully than be stuck on an old librdkafka.

alorbach added a commit to alorbach/rsyslog-pkg-rhel-centos that referenced this issue Nov 14, 2022
- Updated source package for librdkafka.
- Removed libzstd from "buildrequires"
  As it turns out we require to build the libzstd package from
  source ourself which is only be done if the package is NOT installed.
  Using --source-deps-only failed due open issues in the current
  librdkafka branch, so this is the best solution so far.
- updated etc-mock files to allow networking during build.
  This is required if we build libraries from source during
  make.
- With the changes above, static librdkafka libraries are build again
  which will solve the "undefined symbol" issues in rsyslog packages.
  See also: rsyslog/rsyslog#4966

closes: rsyslog#116
@alorbach
Copy link
Member

FINALLY the problem appears to be fixed now in the DAILY stable packages:
http://rpms.adiscon.com/v8-stable-daily/rsyslog-daily.repo

Following PR's fixed problems with the static librdkafka package we need for building (after upgrading to librddkafka 1.9.2):
rsyslog/rsyslog-pkg-rhel-centos#120
rsyslog/rsyslog-pkg-rhel-centos#121

Following PR's fix build problems when --enable-kafka-static is enabled for imkafka and omkafka:
#5026
#5031

I have tested the daily packages using a slightly modified dockerfile from the original post, the kafka modules are loaded and running (and printing failures because there is no kafka server running).

dockerfile.txt

@alorbach
Copy link
Member

alorbach commented Jan 4, 2023

Any Feedback so far? If not I would say this issue can be considered fixed.

@JPvRiel
Copy link
Author

JPvRiel commented Jan 6, 2023

@alorbach, thanks for all the effort with this! We'd worked around it sticking to an older CentOS 7 base image and older version of rsyslog. I'll try test it out within the next week. I read the latest release notes for rsyslog and didn't see this fix mentioned in the change log for 2022.12. Do we need to test from daily, or is it just a omission in the change log given you fixed it well before 2022.12 was released?

@rgerhards
Copy link
Member

Do we need to test from daily, or is it just a omission in the change log given you fixed it well before 2022.12 was released?

Neither - this was just a packaging change, so it does belong and so not appear in the rsyslog ChangeLog. It should be in the package ChangeLog (I haven't checked that one).

JPvRiel added a commit to JPvRiel/docker-rsyslog that referenced this issue Jan 9, 2023
kafka load debug with 8.2212.0 and build fixes from rsyslog/rsyslog#4966 retested
@JPvRiel
Copy link
Author

JPvRiel commented Jan 9, 2023

@alorbach , thanks for the fix! Seems good - no longer seeing "Failed to create thread" errors when loading kafka.

Retested building various base OS containers on 8.2212.0. I was also able to build/rebase https://github.com/JPvRiel/docker-rsyslog on almalinux:8-minimal now which is more recent and less bloated than CentOS7, so thanks!

Base image Result
CentOS 7 OK
RedHat-UBI7 OK
RedHat-UBI8 OK
AlmaLinux 8 OK
RockyLinyx 8 OK
Ubuntu 22.04 OK

@JPvRiel JPvRiel closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants