> On 五月 29, 2021, 2:13 a.m., Madhan Neethiraj wrote:
> > security-admin/src/main/java/org/apache/ranger/common/db/RangerTransactionSynchronizationAdapter.java
> > Lines 158 (patched)
> > <https://reviews.apache.org/r/73365/diff/2/?file=2250332#file2250332line158>
> >
> >     'runnables' parameter is the list from ThreadLocals RUNNABLE and 
> > RUNNABLE_AFTER_COMMIT. No changes to these list should happen while 
> > executing runRunnables() - unless a runnable being executed ends up calling 
> > one of the following methods:
> >     - 
> > RangerTransactionSynchronizationAdapter.executeOnTransactionCompletion()
> >     - RangerTransactionSynchronizationAdapter.executeOnTransactionCommit()
> >     
> >     If above indeed happens, that sounds like a bug. Do you have specific 
> > scenario that triggers this condition?
> >     
> >     Also, I suggest the following to handle this scenario:
> >     
> >     Update the following:
> >       public void afterCompletion(int status) {
> >         ..
> >         runRunnables(RUNNABLES_AFTER_COMMIT.get(), true);
> >         RUNNABLES_AFTER_COMMIT.remove();
> >         ..
> >         runRunnables(RUNNABLES.get(), false);
> >         RUNNABLES.remove();
> >         ..
> >       }
> >     
> >     
> >     To:
> >       public void afterCompletion(int status) {
> >         ..
> >         List<Runnable> runnablesAfterCommit = RUNNABLES_AFTER_COMMIT.get();
> >         List<Runnable> runnables            = RUNNABLES.get();
> >     
> >         RUNNABLES_AFTER_COMMIT.remove();
> >         RUNNABLES.remove();
> >     
> >         runRunnables(runnablesAfterCommit, true);
> >         runRunnables(runnables, false);
> >         ..
> >       }

> Do you have specific scenario that triggers this condition?

I noticed the error when starting ranger with latest source code. The following 
error message is shown below.

2021-05-21 11:26:52,392 [http-nio-6080-exec-1] ERROR 
org.springframework.transaction.support.TransactionSynchronizationUtils 
(TransactionSynchronizationUtils.java:171) - 
TransactionSynchronization.afterCompletion threw exception
java.util.ConcurrentModificationException
        at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:911)
        at java.util.ArrayList$Itr.next(ArrayList.java:861)
        at 
org.apache.ranger.common.db.RangerTransactionSynchronizationAdapter.runRunnables(RangerTransactionSynchronizationAdapter.java:156)
        at 
org.apache.ranger.common.db.RangerTransactionSynchronizationAdapter.afterCompletion(RangerTransactionSynchronizationAdapter.java:122)
        at 
org.springframework.transaction.support.TransactionSynchronizationUtils.invokeAfterCompletion(TransactionSynchronizationUtils.java:168)
        at 
org.springframework.transaction.support.AbstractPlatformTransactionManager.invokeAfterCompletion(AbstractPlatformTransactionManager.java:1006)
        
    
Also, the error can be reproduced quickly by ranger docker script.

> Also, I suggest the following to handle this scenario:

nice suggestion. will copy that


- Chia-Ping


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/73365/#review223076
-----------------------------------------------------------


On 五月 26, 2021, 11:24 a.m., Chia-Ping Tsai wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/73365/
> -----------------------------------------------------------
> 
> (Updated 五月 26, 2021, 11:24 a.m.)
> 
> 
> Review request for ranger and Abhay Kulkarni.
> 
> 
> Bugs: RANGER-3292
>     https://issues.apache.org/jira/browse/RANGER-3292
> 
> 
> Repository: ranger
> 
> 
> Description
> -------
> 
> The root cause is `runnables` get increased when runnable is executing. It 
> can be fixed by using index instead of foreach.
> 
> 
> Diffs
> -----
> 
>   
> security-admin/src/main/java/org/apache/ranger/common/db/RangerTransactionSynchronizationAdapter.java
>  7349898e7 
>   
> security-admin/src/test/java/org/apache/ranger/common/db/TestRangerTransactionSynchronizationAdapter.java
>  PRE-CREATION 
> 
> 
> Diff: https://reviews.apache.org/r/73365/diff/2/
> 
> 
> Testing
> -------
> 
> `mvn clean test` pass on my local and the error does not appear on my local.
> 
> 
> Thanks,
> 
> Chia-Ping Tsai
> 
>

Reply via email to