Bug 1251358 - Skipping unlock when RuntimeException is thrown in AbstractIOService.endBatch()
Skipping unlock when RuntimeException is thrown in AbstractIOService.endBatch()
Status: VERIFIED
Product: JBoss BRMS Platform 6
Classification: JBoss
Component: Business Central (Show other bugs)
6.1.0
Unspecified Unspecified
high Severity high
: ER4
: 6.2.0
Assigned To: Eder Ignatowicz
Jiri Locker
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-07 01:49 EDT by Toshiya Kobayashi
Modified: 2015-11-10 07:39 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
throwRuntimeException.rule (149 bytes, text/plain)
2015-08-07 01:49 EDT, Toshiya Kobayashi
no flags Details

  None (edit)
Description Toshiya Kobayashi 2015-08-07 01:49:01 EDT
Created attachment 1060190 [details]
throwRuntimeException.rule

Description of problem:


AbstractIOService.java
=====
    public void endBatch() {
        if ( !batchLockControl.isLocked() ) {
            throw new RuntimeException( "There is no batch process." );
        }

        if ( batchLockControl.getHoldCount() > 1 ) {
            batchLockControl.unlock();
            return;
        }

        if ( !fileSystems.isEmpty() ) {
            cleanupClosedFileSystems();
        }

        for ( final FileSystem fs : fileSystems ) {
            unsetBatchModeOn( fs );
        }

        batchLockControl.unlock();
    }
=====

If an RuntimeException is thrown before "batchLockControl.unlock()", the lock is not released so subsequent threads will wait for the lock forever.


for example)
=====
09:33:33,821 ERROR [org.kie.workbench.common.screens.explorer.backend.server.ExplorerServiceImpl] (EJB default - 4) Can't serialize user's state navigation: java.lang.RuntimeException: org.eclipse.jgit.errors.MissingObjectException: Missing tree 839a6552f00e82185cec7a0d3878d4db8d41d472
        at org.uberfire.java.nio.fs.jgit.util.JGitUtil.getDiff(JGitUtil.java:457) [uberfire-nio2-jgit-0.5.3.Final-redhat-1.jar:0.5.3.Final-redhat-1]
        at org.uberfire.java.nio.fs.jgit.JGitFileSystemProvider.notifyDiffs(JGitFileSystemProvider.java:1921) [uberfire-nio2-jgit-0.5.3.Final-redhat-1.jar:0.5.3.Final-redhat-1]
        at org.uberfire.java.nio.fs.jgit.JGitFileSystemProvider.notifyAllDiffs(JGitFileSystemProvider.java:1891) [uberfire-nio2-jgit-0.5.3.Final-redhat-1.jar:0.5.3.Final-redhat-1]
        at org.uberfire.java.nio.fs.jgit.JGitFileSystemProvider.setAttribute(JGitFileSystemProvider.java:1681) [uberfire-nio2-jgit-0.5.3.Final-redhat-1.jar:0.5.3.Final-redhat-1]
        at org.uberfire.java.nio.file.Files.setAttribute(Files.java:615) [uberfire-nio2-api-0.5.3.Final-redhat-1.jar:0.5.3.Final-redhat-1]
        at org.uberfire.io.impl.AbstractIOService.unsetBatchModeOn(AbstractIOService.java:191) [uberfire-io-0.5.3.Final-redhat-1.jar:0.5.3.Final-redhat-1]
        at org.uberfire.io.impl.AbstractIOService.endBatch(AbstractIOService.java:169) [uberfire-io-0.5.3.Final-redhat-1.jar:0.5.3.Final-redhat-1]
        at org.kie.workbench.common.screens.explorer.backend.server.ExplorerServiceHelper.store(ExplorerServiceHelper.java:318) [kie-wb-common-project-explorer-backend-6.2.0.Final-redhat-4.jar:6.2.0.Final-redhat-4]
        at org.kie.workbench.common.screens.explorer.backend.server.ExplorerServiceImpl$1.run(ExplorerServiceImpl.java:241) [kie-wb-common-project-explorer-backend-6.2.0.Final
...
====

Steps to Reproduce:
1. Start BRMS
2. Login to business-central
3. Enable the attached byteman rule
$ bin/bminstall.sh <PID>
$ bin/bmsubmit.sh -l throwRuntimeException.rule
4. [Authoring]->[Project Authoring]
 -> an RuntimeException is thrown by byteman. But the browser successfully moves to the [Project Authoring] view
5. [Home]->[Home Page]

Actual results:

The browser cannot move to [Home Page]. Any perspective change doesn't work. If you capture a thread dump, you will see some threads are waiting at org.uberfire.io.lock.BatchLockControl.lock().

Expected results:

The browser can move to [Home Page]
Comment 1 Toshiya Kobayashi 2015-08-07 01:52:24 EDT
Oops, please add the line after step 4 in "Steps to Reproduce:"

=====
Disable the byteman rule
$ bin/bmsubmit.sh -u throwRuntimeException.rule
=====
Comment 2 Eder Ignatowicz 2015-09-22 16:28:25 EDT
Fixed: https://github.com/uberfire/uberfire/commit/00bde1a5e
Comment 3 Jiri Locker 2015-10-26 10:51:06 EDT
Hi Eder, I'm in doubts about that swallowed exception. Leẗ́'s talk about that before I move this ticket.
Comment 4 Eder Ignatowicz 2015-11-09 07:11:13 EST
Hi Jiri!!

Sorry for the delay to answer here.

It's to force the runtime exception. But I agree will be nice to have the stack that originate that.
Do u want to send a PR to fix that? Or I can also do that.

Thanks for the review!
Comment 5 Jiri Locker 2015-11-10 07:39:10 EST
Hi Eder,

PR to master sent https://github.com/uberfire/uberfire/pull/214.

I'm closing the issue as the described issue is fixed. The PR is just a small improvement.

Note You need to log in before you can comment on or make changes to this bug.