Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race conditions when running multiple threads #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Race conditions when running multiple threads #6

wants to merge 1 commit into from

Conversation

michelole
Copy link

JOD Converter still has some race conditions that trigger when several threads request conversions at the same time.

This stress test helps to debug and identify such problems. It creates MAX_RUNNING_THREADS threads to concurrently request up to MAX_CONVERSIONS conversions from RTF to PDF. The threads races for 8 converters, which are restarted after MAX_TASKS_PER_PROCESS conversions each.

After some time running the test, the exception below occurs:

org.artofsolving.jodconverter.office.OfficeException: failed to restart
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess.restartAndWait(ManagedOfficeProcess.java:99)
    at org.artofsolving.jodconverter.office.PooledOfficeManager$2.run(PooledOfficeManager.java:89)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: org.artofsolving.jodconverter.office.OfficeException: could not establish connection
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess.restartAndWait(ManagedOfficeProcess.java:97)
    ... 6 more
Caused by: org.artofsolving.jodconverter.office.OfficeException: could not establish connection
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess.doStartProcessAndConnect(ManagedOfficeProcess.java:162)
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess.access$000(ManagedOfficeProcess.java:25)
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess$3.run(ManagedOfficeProcess.java:93)
    ... 5 more
Caused by: java.lang.IllegalStateException: process with acceptString 'socket,host=127.0.0.1,port=2006' started but its pid could not be found
    at org.artofsolving.jodconverter.office.OfficeProcess.start(OfficeProcess.java:103)
    at org.artofsolving.jodconverter.office.OfficeProcess.start(OfficeProcess.java:64)
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess.doStartProcessAndConnect(ManagedOfficeProcess.java:134)
    ... 7 more

I'm crossposting this pull request for nuxeo and xwiki repositories in the hope of someone helping fix the bug.

@sbraconnier
Copy link

I created a fork and took the liberty to integrate your stress test. I was able to avoid any race conditions with the test you submitted. But I only tested it on Windows and with a LibreOffice version.

If you still are looking for a solution, feel free to test my fork.

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.

2 participants