Skip to content

ZOOKEEPER-5073: Return when C client threads fail to start - #2441

Open
1fanwang wants to merge 1 commit into
apache:masterfrom
1fanwang:fix-zookeeper-init-thread-failure
Open

ZOOKEEPER-5073: Return when C client threads fail to start#2441
1fanwang wants to merge 1 commit into
apache:masterfrom
1fanwang:fix-zookeeper-init-thread-failure

Conversation

@1fanwang

Copy link
Copy Markdown

When the multi-threaded C client cannot create its IO or completion worker, zookeeper_init() never returns in an NDEBUG build. With assertions enabled, the same runtime resource failure aborts the process at pthread_create() failed for the IO thread or pthread_create() failed for the completion thread.

start_threads() now returns the pthread error. If the IO worker started before the completion worker failed, initialization opens the startup barrier, stops and joins that worker, and then releases all adaptor resources. The caller gets NULL with errno set to EAGAIN.

https://issues.apache.org/jira/browse/ZOOKEEPER-5073

Testing

Built and ran the C client tests in the repository's dev/docker image.

Raw logs
# Before, upstream/master 7af463e with the regression tests applied
$ cmake -S zookeeper-client/zookeeper-client-c -B /tmp/build \
    -DCMAKE_BUILD_TYPE=Release -DWANT_CPPUNIT=ON -DWITH_CYRUS_SASL=OFF
$ cmake --build /tmp/build --target zktest -j2
$ timeout 15s /tmp/build/zktest Zookeeper_init::testFirstThreadCreateFailure
exit=124
$ timeout 15s /tmp/build/zktest Zookeeper_init::testSecondThreadCreateFailure
exit=124

# After, f7931a7a0
$ cmake -S zookeeper-client/zookeeper-client-c -B /tmp/release \
    -DCMAKE_BUILD_TYPE=Release -DWANT_CPPUNIT=ON -DWITH_CYRUS_SASL=OFF
$ cmake --build /tmp/release --target zktest -j2
$ base_dir=/workspace timeout 120s /tmp/release/zktest Zookeeper_init
Zookeeper_init::testFirstThreadCreateFailure : OK
Zookeeper_init::testSecondThreadCreateFailure : OK
OK (17)

$ base_dir=/workspace timeout 180s /tmp/release/zktest Zookeeper_close
OK (5)

# Assertions enabled
$ cmake -S zookeeper-client/zookeeper-client-c -B /tmp/debug \
    -DCMAKE_BUILD_TYPE=Debug -DWANT_CPPUNIT=ON -DWITH_CYRUS_SASL=OFF
$ cmake --build /tmp/debug --target zktest -j2
$ base_dir=/workspace timeout 120s /tmp/debug/zktest Zookeeper_init
Zookeeper_init::testFirstThreadCreateFailure : OK
Zookeeper_init::testSecondThreadCreateFailure : OK
OK (17)

# Full suite
$ base_dir=/workspace timeout 600s /tmp/release/zktest all
TestReconfigServer::testNonIncremental
Segmentation fault
exit=139

The full-suite failure is unrelated: TestReconfigServer::testNonIncremental also exits 139 from clean upstream/master at 7af463e0fd5097930f52864911b224d8b9e6a485.

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant