question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible race condition with JUnit 5 in 1.16.1 and 1.16.2

See original GitHub issue

When trying to upgrade from 1.15.3 to 1.16.2 we encountered an issue breaking our tests that might be a race condition.

It seems that connecting to the exposed port is not possible yet when the test cases are executed. Adding timeouts to the @BeforeEach method does reduce these errors which would suggest a race condition here.

I did have a look at PR 4597 and the linked issues. Maybe these could be related but cannot say for sure.

So far I have not been able to create a local reproducer but adding debug logging produces the following output:

[main] INFO 🐳 [rabbitmq:3.8] - Creating container for image: rabbitmq:3.8
[main] INFO 🐳 [rabbitmq:3.8] - Starting container with ID: 633fc3b2f14fb048fd089b805c2596cba8d36358e5802af6e78075f50cfecc96
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 is starting: 633fc3b2f14fb048fd089b805c2596cba8d36358e5802af6e78075f50cfecc96
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 started in PT4.845S
[AMQP Connection 127.0.0.1:49668] WARN com.rabbitmq.client.impl.ForgivingExceptionHandler - An unexpected connection driver error occurred (Exception message: Connection reset)
[main] INFO 🐳 [rabbitmq:3.8] - Creating container for image: rabbitmq:3.8
[main] INFO 🐳 [rabbitmq:3.8] - Starting container with ID: 57d3b35f8cba584142d5efc0c69c1864802b3c977cefddf815cd415b972af66f
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 is starting: 57d3b35f8cba584142d5efc0c69c1864802b3c977cefddf815cd415b972af66f
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 started in PT5.483S
[main] INFO 🐳 [rabbitmq:3.8] - Creating container for image: rabbitmq:3.8
[main] INFO 🐳 [rabbitmq:3.8] - Starting container with ID: 364373afe9fed9056c0314b75709b76a5013c1f7d375089c2329d51686cba14e
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 is starting: 364373afe9fed9056c0314b75709b76a5013c1f7d375089c2329d51686cba14e
[main] INFO 🐳 [rabbitmq:3.8] - Container rabbitmq:3.8 started in PT5.912S

This shows a run of three tests starting a container with a rabbitmq:3.8 image, in our tests we try to connect to that container during the @BeforeEach setup method (Moving this call to the actual test method did not solve the issue). The first test results in an error where as the other two complete successfully. We have also seen runs with all three tests failing.

From the log output it would seem the container is up and running before the test gets executed, the actual behaviour suggests differently. With 1.16.0 or 1.15.3 we did not observe any similar issues.

Connection reset could also imply that the container was shutting down again already but that would be unexpected during the test setup and adding timeout at the start of the setup method should not have an effect on it.

Changing to a shared container instance for all tests did also not solve the issue.

Please let me know if you require any further information.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SanityResortcommented, Nov 16, 2021

Indeed using RabbitMQContainer seems to solve the issue. It is interesting that this has never had an impact before.

Thanks a lot for your help and sorry for this inconvenience.

0reactions
kiviewcommented, Nov 16, 2021

Awesome, great that it works for you now 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is this code not causing a race condition? - Stack Overflow
The below code increments a static variable within a Thread and checks to see if its value is incremented by one. This is...
Read more >
Maximov Konstantin (@KonMaximus) / Twitter
What's Changed 1.16.2 fixes a race condition that was inadvertently added in 1.16.1. This bug can potentially cause unstable builds in some environments, ......
Read more >
Release Notes - Apache Isis
Version Date Features Improves Bugs 2.0.0‑M2 22‑01‑2018 2 36 13 1.17.0 06‑01‑2019 4 17 9 2.0.0‑M1 31‑07‑2018 6 55 + 4 tasks + 13 sub‑tasks 22...
Read more >
Just Enough Items (JEI) - Mods - Minecraft - CurseForge
Filename jei-1.16.5-7.6.1.75.jar ... Basic 1.16.2 Update (#2041) - Johannes ... Fix #1651 Race condition during crash can cause NPE in ...
Read more >
gcc-toolset-11-strace bug fix and enhancement update
[5.13-5] - Fix incorrect ifname printing buffer size (#2028163). This update is available via the Unbreakable Linux Network (ULN) and the Oracle Public...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found