Skip to content

Conversation

@alexcams
Copy link
Contributor

@alexcams alexcams commented Oct 30, 2025

This PR implements thread safety mechanisms during application shutdown and integration tests to avoid transient errors such as these.

Plugin change:

As described in #67 there was a race condition where the consumer tried to ack a message when the channel was closed, raising an ChannelAlreadyClosed exception. This changes include a sync between the plugin shutdown and the consumer thread to avoid acking messages when the channel has been closed.

Integration tests improvements:

Previously, the consumer thread created during each test startup was not stopped gracefully at test closure. This could cause errors , as the consumer thread might attempt to interact with a channel that had already been closed after the test finished.

To address the mutex synchronization error during exchange deletion, the deletion now occurs only after the consumer thread has been gracefully stopped using join function.

Another improvement is the deterministic wait for the channel to have consumers, replacing the previous sleep 4. This change makes test execution faster and more reliable, reducing the wait time from 4 seconds to 1 second per test.

Thanks for contributing to Logstash! If you haven't already signed our CLA, here's a handy link: https://www.elastic.co/contributor-agreement/

@alexcams alexcams marked this pull request as draft October 30, 2025 08:51
@alexcams alexcams force-pushed the ci-fix-integration-tests branch 9 times, most recently from d15551d to 850d822 Compare October 31, 2025 10:32
@alexcams alexcams linked an issue Oct 31, 2025 that may be closed by this pull request
@alexcams alexcams force-pushed the ci-fix-integration-tests branch from 850d822 to d8ebe28 Compare October 31, 2025 10:57
@alexcams alexcams changed the title CI-Fix: Improve integration tests thread safety to avoid race conditions during CI execution Improve thread safety to avoid race conditions during during shutdown. Oct 31, 2025
@alexcams alexcams changed the title Improve thread safety to avoid race conditions during during shutdown. Improve thread safety to avoid race conditions during shutdown. Oct 31, 2025
@alexcams alexcams requested a review from kaisecheng November 4, 2025 08:54
@alexcams alexcams marked this pull request as ready for review November 4, 2025 08:55
Copy link
Contributor

@kaisecheng kaisecheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for improving and speeding up the tests

@alexcams alexcams merged commit 7ae6dcd into logstash-plugins:main Nov 4, 2025
3 checks passed
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.

Avoid acknowledge last message if the channel is already closed

2 participants