Confluent-kafka-dotnet: "InvalidOperationException: Failed to create thread" on Alpine Linux 3.7

Created on 26 Jun 2018  路  16Comments  路  Source: confluentinc/confluent-kafka-dotnet

Description

On Alpine Linux with .NET Core 2.1 and installed librdkafka consumer's .ctor raises following exception:

Unhandled Exception: System.InvalidOperationException: Failed to create thread: No error information (0)
   at Confluent.Kafka.Impl.SafeKafkaHandle.Create(RdKafkaType type, IntPtr config)
   at Confluent.Kafka.Consumer..ctor(IEnumerable`1 config)
   at Confluent.Kafka.Consumer`2..ctor(IEnumerable`1 config, IDeserializer`1 keyDeserializer, IDeserializer`1 valueDeserializer)
   at app.Program.Main(String[] args) in /app/Program.cs:line 9

Without installed librdkafka I get following exception:

Unhandled Exception: System.DllNotFoundException: Failed to load the librdkafka native library.
   at Confluent.Kafka.Impl.LibRdKafka.Initialize(String userSpecifiedPath)
   at Confluent.Kafka.Consumer..ctor(IEnumerable`1 config)
   at Confluent.Kafka.Consumer`2..ctor(IEnumerable`1 config, IDeserializer`1 keyDeserializer, IDeserializer`1 valueDeserializer)
   at app.Program.Main(String[] args) in /app/Program.cs:line 9

How to reproduce

  1. docker build --tag repro-image . with following Dockerfile:
FROM microsoft/dotnet:2.1.301-sdk-alpine3.7

WORKDIR /app

# Install requirements
RUN apk add --update \
        bash \
        git \
        make \
        gcc \
        g++

# Build librdkafka from source
RUN git clone https://github.com/edenhill/librdkafka.git /librdkafka \
    && cd /librdkafka \
    && git checkout v0.11.4 \
    && ./configure \
    && make \
    && make install

# Create .NET Core console app
RUN cd /app \
    && dotnet new console \
    && dotnet add package -v 0.11.4 Confluent.Kafka
  1. docker run -it repro-image
  2. Fill Program.cs:
namespace app
{
    class Program
    {
        static void Main(string[] args)
        {
            var loaded = Confluent.Kafka.Library.Load("/usr/local/lib/librdkafka.so");
            System.Console.WriteLine("Library is loaded: " + loaded.ToString());
            var consumer = new Confluent.Kafka.Consumer<string, string>(
                new System.Collections.Generic.Dictionary<string, object>{{ "group.id", "test" }, { "debug", "all" }},
                new Confluent.Kafka.Serialization.StringDeserializer(System.Text.Encoding.UTF8),
                new Confluent.Kafka.Serialization.StringDeserializer(System.Text.Encoding.UTF8));
        }
    }
}
  1. dotnet run

Checklist

Please provide the following information:

  • [x] Confluent.Kafka nuget version: 0.11.4
  • [x] Operating system: Alpine Linux 3.7

    • [ ] Apache Kafka version:

  • [ ] Client configuration:

    • [ ] Provide logs (with "debug" : "..." as necessary in configuration)

  • [ ] Provide broker log excerpts
  • [ ] Critical issue
enhancement librdkafka

Most helpful comment

i've changed the labelling on this to 'enhancement' - we are considering adding out-of-the box support for alpine linux (given there is an official dotnet docker image based on this distro). This comes with the downside of increasing the size of librdkafka.redist however. Please +1 if you'd find this useful.

All 16 comments

what's the output of ldd /usr/local/lib/librdkafka.so?

/ # ldd /usr/local/lib/librdkafka.so
        ldd (0x7f596f392000)
        libc.musl-x86_64.so.1 => ldd (0x7f596f392000)

/ # find /usr/local/ -name "*kafka*"
/usr/local/lib/librdkafka++.so
/usr/local/lib/librdkafka++.so.1
/usr/local/lib/pkgconfig/rdkafka-static.pc
/usr/local/lib/pkgconfig/rdkafka.pc
/usr/local/lib/pkgconfig/rdkafka++-static.pc
/usr/local/lib/pkgconfig/rdkafka++.pc
/usr/local/lib/librdkafka.so
/usr/local/lib/librdkafka.a
/usr/local/lib/librdkafka++.a
/usr/local/lib/librdkafka.so.1
/usr/local/include/librdkafka
/usr/local/include/librdkafka/rdkafka.h
/usr/local/include/librdkafka/rdkafkacpp.h

the output of ldd looks oddly sparse to me, I would expect to see for example libpthread and libresolv in there (and if they're not on the system, marked as missing). maybe look at the output of ./configure, make and make install for clues? The error message you're seeing is consistent with missing librdkafka dependencies.

Output of ./configure:

checking for OS or distribution... ok (Linux)
checking for C compiler from CC env... failed
checking for gcc (by command)... ok
checking for C++ compiler from CXX env... failed
checking for C++ compiler (g++)... ok
checking executable ld... ok
checking executable nm... ok
checking executable objdump... ok
checking executable strip... ok
checking for pkgconfig (by command)... ok
checking for install (by command)... failed
checking for PIC (by compile)... ok
checking for GNU-compatible linker options... ok
checking for GNU linker-script ld flag... ok
checking for __atomic_32 (by compile)... ok
checking for __atomic_64 (by compile)... ok
checking for socket (by compile)... ok
parsing version '0x000b04ff'... ok (0.11.4)
checking for librt (by pkg-config)... failed
checking for librt (by compile)... ok
checking for libpthread (by pkg-config)... failed
checking for libpthread (by compile)... ok
checking for libdl (by pkg-config)... failed
checking for libdl (by compile)... ok
checking for zlib (by pkg-config)... failed
checking for zlib (by compile)... failed (disable)
checking for libcrypto (by pkg-config)... failed
checking for libcrypto (by compile)... failed (disable)
checking for liblz4 (by pkg-config)... failed
checking for liblz4 (by compile)... failed (disable)
checking for libssl (by pkg-config)... failed
checking for libssl (by compile)... failed (disable)
checking for libsasl2 (by pkg-config)... failed
checking for libsasl2 (by compile)... failed (disable)
checking for libsasl (by pkg-config)... failed
checking for libsasl (by compile)... failed (disable)
checking for crc32chw (by compile)... ok
checking for regex (by compile)... ok
checking for strndup (by compile)... ok
checking for strerror_r (by compile)... ok
checking for pthread_setname_gnu (by compile)... ok
checking for nm (by env NM)... ok (cached)
checking for python (by command)... failed (disable)
disabling linker-script since python is not available
Generated Makefile.config
Generated config.h

Configuration summary:
  prefix                   /usr/local
  ARCH                     x86_64
  CPU                      generic
  GEN_PKG_CONFIG           y
  ENABLE_DEVEL             n
  ENABLE_VALGRIND          n
  ENABLE_REFCNT_DEBUG      n
  ENABLE_SHAREDPTR_DEBUG   n
  ENABLE_LZ4_EXT           y
  ENABLE_SSL               y
  ENABLE_SASL              y
  MKL_APP_NAME             librdkafka
  MKL_APP_DESC_ONELINE     The Apache Kafka C/C++ library
  MKL_DISTRO               Linux
  SOLIB_EXT                .so
  CC                       gcc
  CXX                      g++
  LD                       ld
  NM                       nm
  OBJDUMP                  objdump
  STRIP                    strip
  CPPFLAGS                 -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align
  PKG_CONFIG               pkg-config
  INSTALL                  install
  LIB_LDFLAGS              -shared -Wl,-soname,$(LIBFILENAME)
  LDFLAG_LINKERSCRIPT      -Wl,--version-script=
  RDKAFKA_VERSION_STR      0.11.4
  MKL_APP_VERSION          0.11.4
  LIBS                     -ldl -lpthread -lrt
  CXXFLAGS                 -Wno-non-virtual-dtor
  SYMDUMPER                $(NM) -D
  exec_prefix              /usr/local
  bindir                   /usr/local/bin
  sbindir                  /usr/local/sbin
  libexecdir               /usr/local/libexec
  datadir                  /usr/local/share
  sysconfdir               /usr/local/etc
  sharedstatedir           /usr/local/com
  localstatedir            /usr/local/var
  libdir                   /usr/local/lib
  includedir               /usr/local/include
  infodir                  /usr/local/info
  mandir                   /usr/local/man
Generated config.cache

Now type 'make' to build

Output of make:

make[1]: Entering directory '/librdkafka/src'
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka.c -o rdkafka.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_broker.c -o rdkafka_broker.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_msg.c -o rdkafka_msg.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_topic.c -o rdkafka_topic.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_conf.c -o rdkafka_conf.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_timer.c -o rdkafka_timer.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_offset.c -o rdkafka_offset.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_transport.c -o rdkafka_transport.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_buf.c -o rdkafka_buf.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_queue.c -o rdkafka_queue.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_op.c -o rdkafka_op.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_request.c -o rdkafka_request.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_cgrp.c -o rdkafka_cgrp.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_pattern.c -o rdkafka_pattern.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_partition.c -o rdkafka_partition.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_subscription.c -o rdkafka_subscription.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_assignor.c -o rdkafka_assignor.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_range_assignor.c -o rdkafka_range_assignor.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_roundrobin_assignor.c -o rdkafka_roundrobin_assignor.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_feature.c -o rdkafka_feature.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdcrc32.c -o rdcrc32.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c crc32c.c -o crc32c.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdmurmur2.c -o rdmurmur2.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdaddr.c -o rdaddr.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdrand.c -o rdrand.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdlist.c -o rdlist.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c tinycthread.c -o tinycthread.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdlog.c -o rdlog.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdstring.c -o rdstring.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_event.c -o rdkafka_event.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_metadata.c -o rdkafka_metadata.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdregex.c -o rdregex.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdports.c -o rdports.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_metadata_cache.c -o rdkafka_metadata_cache.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdavl.c -o rdavl.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_sasl.c -o rdkafka_sasl.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_sasl_plain.c -o rdkafka_sasl_plain.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_interceptor.c -o rdkafka_interceptor.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_msgset_writer.c -o rdkafka_msgset_writer.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_msgset_reader.c -o rdkafka_msgset_reader.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_header.c -o rdkafka_header.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdvarint.c -o rdvarint.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdbuf.c -o rdbuf.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdunittest.c -o rdunittest.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c snappy.c -o snappy.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_lz4.c -o rdkafka_lz4.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -O3 -c xxhash.c -o xxhash.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -O3 -c lz4.c -o lz4.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -O3 -c lz4frame.c -o lz4frame.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -O3 -c lz4hc.c -o lz4hc.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rddl.c -o rddl.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -DLIBRDKAFKA_GIT_VERSION="\"v0.11.4\""  -c rdkafka_plugin.c -o rdkafka_plugin.o
Creating shared library librdkafka.so.1
gcc  -shared -Wl,-soname,librdkafka.so.1 rdkafka.o rdkafka_broker.o rdkafka_msg.o rdkafka_topic.o rdkafka_conf.o rdkafka_timer.o rdkafka_offset.o rdkafka_transport.o rdkafka_buf.o rdkafka_queue.o rdkafka_op.o rdkafka_request.o rdkafka_cgrp.o rdkafka_pattern.o rdkafka_partition.o rdkafka_subscription.o rdkafka_assignor.o rdkafka_range_assignor.o rdkafka_roundrobin_assignor.o rdkafka_feature.o rdcrc32.o crc32c.o rdmurmur2.o rdaddr.o rdrand.o rdlist.o tinycthread.o rdlog.o rdstring.o rdkafka_event.o rdkafka_metadata.o rdregex.o rdports.o rdkafka_metadata_cache.o rdavl.o rdkafka_sasl.o rdkafka_sasl_plain.o rdkafka_interceptor.o rdkafka_msgset_writer.o rdkafka_msgset_reader.o rdkafka_header.o rdvarint.o rdbuf.o rdunittest.o snappy.o rdkafka_lz4.o xxhash.o lz4.o lz4frame.o lz4hc.o rddl.o rdkafka_plugin.o -o librdkafka.so.1 -ldl -lpthread -lrt
Creating static library librdkafka.a
ar rcs librdkafka.a rdkafka.o rdkafka_broker.o rdkafka_msg.o rdkafka_topic.o rdkafka_conf.o rdkafka_timer.o rdkafka_offset.o rdkafka_transport.o rdkafka_buf.o rdkafka_queue.o rdkafka_op.o rdkafka_request.o rdkafka_cgrp.o rdkafka_pattern.o rdkafka_partition.o rdkafka_subscription.o rdkafka_assignor.o rdkafka_range_assignor.o rdkafka_roundrobin_assignor.o rdkafka_feature.o rdcrc32.o crc32c.o rdmurmur2.o rdaddr.o rdrand.o rdlist.o tinycthread.o rdlog.o rdstring.o rdkafka_event.o rdkafka_metadata.o rdregex.o rdports.o rdkafka_metadata_cache.o rdavl.o rdkafka_sasl.o rdkafka_sasl_plain.o rdkafka_interceptor.o rdkafka_msgset_writer.o rdkafka_msgset_reader.o rdkafka_header.o rdvarint.o rdbuf.o rdunittest.o snappy.o rdkafka_lz4.o xxhash.o lz4.o lz4frame.o lz4hc.o rddl.o rdkafka_plugin.o
Creating librdkafka.so symlink
rm -f "librdkafka.so" && ln -s "librdkafka.so.1" "librdkafka.so"
Generating pkg-config file rdkafka.pc
Generating pkg-config file rdkafka-static.pc
Checking librdkafka integrity
librdkafka.so.1                OK
librdkafka.a                   OK
Symbol visibility              OK
make[1]: Leaving directory '/librdkafka/src'
make[1]: Entering directory '/librdkafka/src-cpp'
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c RdKafka.cpp -o RdKafka.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c ConfImpl.cpp -o ConfImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c HandleImpl.cpp -o HandleImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c ConsumerImpl.cpp -o ConsumerImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c ProducerImpl.cpp -o ProducerImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c KafkaConsumerImpl.cpp -o KafkaConsumerImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c TopicImpl.cpp -o TopicImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c TopicPartitionImpl.cpp -o TopicPartitionImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c MessageImpl.cpp -o MessageImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c QueueImpl.cpp -o QueueImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c MetadataImpl.cpp -o MetadataImpl.o
Creating shared library librdkafka++.so.1
gcc  -shared -Wl,-soname,librdkafka++.so.1 RdKafka.o ConfImpl.o HandleImpl.o ConsumerImpl.o ProducerImpl.o KafkaConsumerImpl.o TopicImpl.o TopicPartitionImpl.o MessageImpl.o QueueImpl.o MetadataImpl.o -o librdkafka++.so.1 -L../src -lrdkafka -lstdc++
Creating static library librdkafka++.a
ar rcs librdkafka++.a RdKafka.o ConfImpl.o HandleImpl.o ConsumerImpl.o ProducerImpl.o KafkaConsumerImpl.o TopicImpl.o TopicPartitionImpl.o MessageImpl.o QueueImpl.o MetadataImpl.o
Creating librdkafka++.so symlink
rm -f "librdkafka++.so" && ln -s "librdkafka++.so.1" "librdkafka++.so"
Generating pkg-config file rdkafka++.pc
Generating pkg-config file rdkafka++-static.pc
Checking librdkafka++ integrity
librdkafka++.so.1              OK
librdkafka++.a                 OK
make[1]: Leaving directory '/librdkafka/src-cpp'
make -C examples
make[1]: Entering directory '/librdkafka/examples'
gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src rdkafka_example.c -o rdkafka_example  \
        ../src/librdkafka.a -ldl -lpthread -lrt
# rdkafka_example is ready
#
# Run producer (write messages on stdin)
./rdkafka_example -P -t <topic> -p <partition>

# or consumer
./rdkafka_example -C -t <topic> -p <partition>

#
# More usage options:
./rdkafka_example -h
gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src rdkafka_performance.c -o rdkafka_performance  \
        ../src/librdkafka.a -ldl -lpthread -lrt
# rdkafka_performance is ready
#
# Run producer
./rdkafka_performance -P -t <topic> -p <partition> -s <msgsize>

# or consumer
./rdkafka_performance -C -t <topic> -p <partition>

#
# More usage options:
./rdkafka_performance -h
g++ -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -I../src-cpp rdkafka_example.cpp -o rdkafka_example_cpp  \
        ../src-cpp/librdkafka++.a ../src/librdkafka.a -ldl -lpthread -lrt -lstdc++
gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src rdkafka_consumer_example.c -o rdkafka_consumer_example  \
        ../src/librdkafka.a -ldl -lpthread -lrt
# rdkafka_consumer_example is ready
#
./rdkafka_consumer_example <topic[:part]> <topic2[:part]> ..

#
# More usage options:
./rdkafka_consumer_example -h
g++ -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -I../src-cpp rdkafka_consumer_example.cpp -o rdkafka_consumer_example_cpp  \
        ../src-cpp/librdkafka++.a ../src/librdkafka.a -ldl -lpthread -lrt -lstdc++
g++ -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -I../src-cpp kafkatest_verifiable_client.cpp -o kafkatest_verifiable_client  \
        ../src-cpp/librdkafka++.a ../src/librdkafka.a -ldl -lpthread -lrt -lstdc++
gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src rdkafka_simple_producer.c -o rdkafka_simple_producer  \
        ../src/librdkafka.a -ldl -lpthread -lrt
make[1]: Leaving directory '/librdkafka/examples'
Updating
CONFIGURATION.md CONFIGURATION.md.tmp differ: char 330, line 6
Checking  integrity
CONFIGURATION.md               OK
examples/rdkafka_example       OK
examples/rdkafka_performance   OK
examples/rdkafka_example_cpp   OK
make[1]: Entering directory '/librdkafka/src'
Creating shared library librdkafka.so.1
gcc  -shared -Wl,-soname,librdkafka.so.1 rdkafka.o rdkafka_broker.o rdkafka_msg.o rdkafka_topic.o rdkafka_conf.o rdkafka_timer.o rdkafka_offset.o rdkafka_transport.o rdkafka_buf.o rdkafka_queue.o rdkafka_op.o rdkafka_request.o rdkafka_cgrp.o rdkafka_pattern.o rdkafka_partition.o rdkafka_subscription.o rdkafka_assignor.o rdkafka_range_assignor.o rdkafka_roundrobin_assignor.o rdkafka_feature.o rdcrc32.o crc32c.o rdmurmur2.o rdaddr.o rdrand.o rdlist.o tinycthread.o rdlog.o rdstring.o rdkafka_event.o rdkafka_metadata.o rdregex.o rdports.o rdkafka_metadata_cache.o rdavl.o rdkafka_sasl.o rdkafka_sasl_plain.o rdkafka_interceptor.o rdkafka_msgset_writer.o rdkafka_msgset_reader.o rdkafka_header.o rdvarint.o rdbuf.o rdunittest.o snappy.o rdkafka_lz4.o xxhash.o lz4.o lz4frame.o lz4hc.o rddl.o rdkafka_plugin.o -o librdkafka.so.1 -ldl -lpthread -lrt
Checking librdkafka integrity
librdkafka.so.1                OK
librdkafka.a                   OK
Symbol visibility              OK
make[1]: Leaving directory '/librdkafka/src'
make[1]: Entering directory '/librdkafka/src-cpp'
Creating shared library librdkafka++.so.1
gcc  -shared -Wl,-soname,librdkafka++.so.1 RdKafka.o ConfImpl.o HandleImpl.o ConsumerImpl.o ProducerImpl.o KafkaConsumerImpl.o TopicImpl.o TopicPartitionImpl.o MessageImpl.o QueueImpl.o MetadataImpl.o -o librdkafka++.so.1 -L../src -lrdkafka -lstdc++
Checking librdkafka++ integrity
librdkafka++.so.1              OK
librdkafka++.a                 OK
make[1]: Leaving directory '/librdkafka/src-cpp'

Output of make install:

make[1]: Entering directory '/librdkafka/src'
Install librdkafka to /usr/local
install -d $DESTDIR/usr/local/include/librdkafka ; \
install -d $DESTDIR/usr/local/lib ; \
install rdkafka.h $DESTDIR/usr/local/include/librdkafka ; \
install librdkafka.a $DESTDIR/usr/local/lib ; \
install librdkafka.so.1 $DESTDIR/usr/local/lib ; \
[ -f "rdkafka.pc" ] && ( \
        install -d $DESTDIR/usr/local/lib/pkgconfig ; \
        install -m 0644 rdkafka.pc $DESTDIR/usr/local/lib/pkgconfig \
) ; \
[ -f "rdkafka-static.pc" ] && ( \
        install -d $DESTDIR/usr/local/lib/pkgconfig ; \
        install -m 0644 rdkafka-static.pc $DESTDIR/usr/local/lib/pkgconfig \
) ; \
(cd $DESTDIR/usr/local/lib && ln -sf librdkafka.so.1 librdkafka.so)
make[1]: Leaving directory '/librdkafka/src'
make[1]: Entering directory '/librdkafka/src-cpp'
Install librdkafka++ to /usr/local
install -d $DESTDIR/usr/local/include/librdkafka ; \
install -d $DESTDIR/usr/local/lib ; \
install rdkafkacpp.h $DESTDIR/usr/local/include/librdkafka ; \
install librdkafka++.a $DESTDIR/usr/local/lib ; \
install librdkafka++.so.1 $DESTDIR/usr/local/lib ; \
[ -f "rdkafka++.pc" ] && ( \
        install -d $DESTDIR/usr/local/lib/pkgconfig ; \
        install -m 0644 rdkafka++.pc $DESTDIR/usr/local/lib/pkgconfig \
) ; \
[ -f "rdkafka++-static.pc" ] && ( \
        install -d $DESTDIR/usr/local/lib/pkgconfig ; \
        install -m 0644 rdkafka++-static.pc $DESTDIR/usr/local/lib/pkgconfig \
) ; \
(cd $DESTDIR/usr/local/lib && ln -sf librdkafka++.so.1 librdkafka++.so)
make[1]: Leaving directory '/librdkafka/src-cpp'

My notes:

  1. Without librdkafka installed, i also see Unhandled Exception: System.DllNotFoundException: Failed to load the librdkafka native library., which i'd expect since there isn't a compatible librdkafka version bundled in librdkafka.redist.
  2. I compiled librdkafka inside the docker image as you did.
  3. The examples that come with librdkafka work fine.
  4. Library.Load in .NET appears to work.
  5. Constructing the producer hangs for me.

There are a number of calls into librdkafka in the constructor.

What I'd do next is link against the Confluent.Kafka project (as opposed to package) inside the docker image and insert debug console.writeline's in the producer constructor to work out which librdkafka call is hanging. I'd then start inserting printf's inside that method inside the librdkafka code to work out what's going on there.

@edenhill do you have any intuition as to what's going on?

Not really, I :+1: your writeline/printf approach (you might get away with debug=all for the librdkafka case, it logs quite early in its construction)

oh, i also had debug / all set and saw no output.

@xakep139 - just a heads up that there are quite a few things ahead of this in priority (this is the first time this issue has been brought up), so i don't think i'll get time to investigate more in say the next week or two. If you get anywhere please update :-).

Sorry for the delay. I've figured out that initial error is filled by this line - rdkafka.c#L1700 (call from SafeKafkaHandle.cs#L94). Seems like it's call in tinycthread.c.
However, it seems odd to me that sometimes consumer doesn't throw any exceptions and hangs program unexpectedly (without any exception, even with try block) with exit code 139. Sometimes it just waits infinitely without any output and without consuming CPU.
With "debug" / "all" I see only one message from librdkafka:

7|2018-07-09 11:16:08.675|rdkafka#consumer-1|MEMBERID| [thrd:app]: Group "test": updating member id "(not-set)" -> ""

I've tried to create producer as well and got same behaviour except getting an exception.

The problem is that I cannot use any of the Alpine-based dotnet Docker images

thanks for following up on this @xakep139 - looks like the same problem as https://github.com/Blizzard/node-rdkafka/issues/361 with workaround: https://github.com/Blizzard/node-rdkafka/blob/master/examples/docker-alpine.md

alpine has a lightweight version of glibc that causes a lot of problems with threading. I believe you need a full featured glibc in order to get it to work.

@mhowlett, I've just added python in apk add list and everything worked. It's very strange, because just adding all of python deps didn't help and Python itself doesn't need to build librdkafka.
After make install I could safely delete all these packages and both Consumer and Producer work as expected.

@edenhill, could you add build for Alpine in librdkafka.redist package? Here's the Dockerfile to build:

FROM alpine:3.7

WORKDIR /librdkafka

# Install requirements
RUN apk add --no-cache --virtual .build-deps \
    bash \
    g++ \
    gcc \
    git \
    make \
    python \
# Optional deps to build with ssl, lz4:
    lz4-dev \
    cyrus-sasl-dev \
    openssl-dev

# Build librdkafka from source
RUN git clone https://github.com/edenhill/librdkafka.git . \
    && git checkout v0.11.4 \
    && ./configure \
    && make

i've changed the labelling on this to 'enhancement' - we are considering adding out-of-the box support for alpine linux (given there is an official dotnet docker image based on this distro). This comes with the downside of increasing the size of librdkafka.redist however. Please +1 if you'd find this useful.

@mhowlett do you still plan to add build of librdkafka for Alpine Linux in librdkafka.redist?

@mhowlett?

yes for sure. I don't know if this'll make it into 1.0 but it's certainly a candidate for that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ravindranrajendran picture Ravindranrajendran  路  3Comments

Eibwen picture Eibwen  路  3Comments

keggster101020 picture keggster101020  路  4Comments

jeffreycruzana picture jeffreycruzana  路  3Comments

farodin91 picture farodin91  路  3Comments