ch.vorburger.exec icon indicating copy to clipboard operation
ch.vorburger.exec copied to clipboard

Unexpected error when calling waitForExit

Open mihneagiurgea opened this issue 4 years ago • 6 comments
trafficstars

Here's the issue that we're seeing:

ManagedProcess process = builder.build();
process.start();
process.waitForExit(); // Crashes the error below:

waitForExit fails with this:

Caused by: ch.vorburger.exec.ManagedProcessException: Asked to waitFor Program 
[/tmp/75968747865555/MysqlDB4j/base/bin/mysql, -uroot, --socket=/tmp/75968747865555/MysqlDB4j.33803.sock] 
(in working directory /tmp/75968747865555/MysqlDB4j/base), but it was never even start()'ed! |
  |   | at ch.vorburger.exec.ManagedProcess.assertWaitForIsValid(ManagedProcess.java:478)
  |   | at ch.vorburger.exec.ManagedProcess.waitForExitMaxMsWithoutLog(ManagedProcess.java:439) |  
  |   | at ch.vorburger.exec.ManagedProcess.waitForExit(ManagedProcess.java:418) |  
  |   | at com.airbnb.mysql4j.DB.run(DB.java:405) |  
[...]

This is failing randomly, at a rate of say 5%. Succeeds after retries.

Based on the comment from here: https://github.com/vorburger/ch.vorburger.exec/blob/07f251115af56a4f6d38eb46cb2cbd76d10a10ed/src/main/java/ch/vorburger/exec/ManagedProcess.java#L198

... I suspect (without being able to prove this via a test) that what's happening is this, inside startExecute()

  1. executor.execute starts execution of something that will fail
  2. this.wait(100) returns with no error, but incorrectly fails to detect that the background thread has an error
  3. isAlive = watchDog.isWatching() correctly returns False, because the background thread has indeed failed
  4. waitForExit will call assertWaitForIsValid(), which throws because isAlive = False (from 3) and hasResult = False (from 2)

mihneagiurgea avatar Dec 07 '20 22:12 mihneagiurgea

@mihneagiurgea do you want to check if #96 from @cardamon might fix this problem?

vorburger avatar Mar 06 '23 14:03 vorburger

@mihneagiurgea if you are still seeing this with the new 3.1.5 I am about to release, I would welcome a PR to fix!

vorburger avatar May 13 '23 13:05 vorburger

@mosesn perhaps you would like to chime in here - do you know if this one can be closed? Still needs a fix?

vorburger avatar May 14 '23 10:05 vorburger

I'm still working on the MariaDB4J upgrade–the SLF4J 2.x upgrade is incompatible with some of the versions of the other libraries we use (Spark, Dropwizard, etc) so it has been a bit of a slog. I'm hoping to merge it in soon, and I should be able to give you better feedback once that's done.

mosesn avatar May 14 '23 13:05 mosesn