Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1251358

Summary: Skipping unlock when RuntimeException is thrown in AbstractIOService.endBatch()
Product: [Retired] JBoss BRMS Platform 6 Reporter: Toshiya Kobayashi <tkobayas>
Component: Business CentralAssignee: Eder Ignatowicz <eignatow>
Status: CLOSED EOL QA Contact: Jiri Locker <jlocker>
Severity: high Docs Contact:
Priority: high    
Version: 6.1.0CC: eignatow, etirelli
Target Milestone: ER4   
Target Release: 6.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-27 19:01:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
throwRuntimeException.rule none

Description Toshiya Kobayashi 2015-08-07 05:49:01 UTC
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 05:52:24 UTC
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 20:28:25 UTC
Fixed: https://github.com/uberfire/uberfire/commit/00bde1a5e

Comment 3 Jiri Locker 2015-10-26 14:51:06 UTC
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 12:11:13 UTC
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 12:39:10 UTC
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.