[
https://issues.apache.org/jira/browse/TINKERPOP-1505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16096767#comment-16096767
]
stephen mallette commented on TINKERPOP-1505:
---------------------------------------------
Spent a little time thinking about this as we'd hoped to make a fix for 3.3.0.
We never really discussed major changes to transactions so at this point, such
a thing would be beyond the scope of what is possible for 3.3.0. I'd dare say
it is beyond the scope of 3.x period. I looked for some workarounds for this
problem and realized that there might be a way to trigger an init script per
thread in the {{GremlinExecutor}} but it's not a perfect fit as there are some
chicken/egg problems with how it would work. Like the current init script
shouldn't be executed per thread so there's like a "server init script" and a
"script engine init script". I thought we could piggy-back on the server init
script through the {{LifeCycle}} but that would mean we'd have to eval the
script first to get the {{LifeCycle}} object....but oops! then we initialized
at least one thread using the script engine already and we won't get a second
chance to do so. perhaps there are ways around that but that's when stuff
sounded hacky and i backed away. Not sure if we'll see a legit fix on this for
3.x.
> Transaction Status listener list gets overwritten
> -------------------------------------------------
>
> Key: TINKERPOP-1505
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1505
> Project: TinkerPop
> Issue Type: Bug
> Components: process
> Affects Versions: 3.1.4, 3.2.2
> Reporter: Jason Plurad
>
> Transaction status listener is not called when using Gremlin Server
> * Caused by the transaction listener list initialization in
> [AbstractThreadLocalTransaction|https://github.com/apache/tinkerpop/blob/3.1.4/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractThreadLocalTransaction.java#L54-L59].
>
> * There are 2 different threads in action during the Gremlin Server
> initialization.
> # The Groovy startup script evaluation which adds the listener
> # The server itself handles the transaction commit or rollback. Both
> threads end up calling on the {{ThreadLocal initialValue()}} which returns
> {{new ArrayList()}} and effectively wipes out the listener.
> * Fix is to initialize the list once.
> {noformat}
> protected final ThreadLocal<List<Consumer<Transaction.Status>>>
> transactionListeners = new ThreadLocal<List<Consumer<Transaction.Status>>>() {
> private List<Consumer<Transaction.Status>> list = new ArrayList<>();
> @Override
> protected List<Consumer<Transaction.Status>> initialValue() {
> return list;
> }
> };
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)