incubator-hugegraph icon indicating copy to clipboard operation
incubator-hugegraph copied to clipboard

[Bug] tx leak when stopping server

Open VGalaxies opened this issue 1 year ago • 1 comments

Bug Type (问题类型)

server status (启动/运行异常)

Before submit

  • [X] 我已经确认现有的 IssuesFAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)

Related PRs:

  • https://github.com/apache/incubator-hugegraph/pull/2031

Environment (环境信息)

  • Server Version: 1.0.0 (Apache Release Version)
  • Backend: RocksDB x nodes, HDD or SSD
  • OS: x86_64 Linux 6.4.3-arch1-2

Expected & Actual behavior (期望与实际表现)

When I try to stop the server (by script or in IDEA), the following error occurs:

2023-09-14 14:34:00 [gremlin-server-stop] [WARN] o.a.t.g.s.GremlinServer - Exception while closing Graph instance [hugegraph]
java.lang.IllegalStateException: Ensure tx closed in all threads when closing graph 'hugegraph'
	at com.google.common.base.Preconditions.checkState(Preconditions.java:531) ~[guava-25.1-jre.jar:?]
	at org.apache.hugegraph.util.E.checkState(E.java:64) ~[hugegraph-common-1.0.0.jar:1.0.0]
	at org.apache.hugegraph.StandardHugeGraph.close(StandardHugeGraph.java:971) ~[hugegraph-core-1.0.0.jar:1.0.0]
	at org.apache.tinkerpop.gremlin.server.GremlinServer.lambda$null$7(GremlinServer.java:307) ~[gremlin-server-3.5.1.jar:3.5.1]
	at java.util.concurrent.ConcurrentHashMap$KeySetView.forEach(ConcurrentHashMap.java:4696) ~[?:?]
	at org.apache.tinkerpop.gremlin.server.GremlinServer.lambda$stop$8(GremlinServer.java:304) ~[gremlin-server-3.5.1.jar:3.5.1]
	at java.lang.Thread.run(Thread.java:829) [?:?]

This is because after closing, the refs in TinkerPopTransaction are not zeroed:

public boolean closed() {
    int refs = this.refs.get();
    assert refs >= 0 : refs;
    return refs == 0;
}

By logging the value of refs, I noticed that when configuring org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin as scripts/empty-sample.groovy in conf/gremlin-server.yaml, the refs value is 1. When configured as scripts/example.groovy, the refs value is 2. 🤔

Vertex/Edge example (问题点 / 边数据举例)

No response

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

No response

VGalaxies avatar Sep 14 '23 07:09 VGalaxies

This is a known issue, but currently there is no perfect solution. @zyxxoo can you take a look?

javeme avatar Sep 14 '23 10:09 javeme