无法在基于 EC2 的 Cassandra 后端获取写锁
Can not acquire write lock on EC2-based Cassandra backend
我已经部署了 Cassandra 3.11.1 on an EC2 instance and connecting to it from my machine using the JanusGraph Java API。出于测试目的,该实例允许所有入站和出站 TCP 连接。
在 cassandra.yaml
文件中,我配置了如下值:
listen_address
: 私有 EC2 地址
broadcast_address
: public EC2 地址
seeds
: public EC2 地址
start_rpc: true
rpc_address
: 私有 EC2 地址
endpoint_snitch: Ec2MultiRegionSnitch
注意当我想使用publicEC2地址作为rpc_address
时,Cassandra启动失败这条消息:
Failed to bind port 9042 on <public EC2 address>
最后我尝试连接到图形,添加一个顶点并提交。
JanusGraph graph = JanusGraphFactory.build()
.set("storage.backend", "cassandra")
.set("storage.hostname", "<public EC2 address>")
.set("storage.cassandra.keyspace", "debug")
.set("storage.batch-loading", false)
.set("query.force-index", false)
.set("query.fast-property", true)
.set("cache.db-cache", true)
.set("schema.default", "default")
.set("index.search.backend", "elasticsearch")
.set("index.search.hostname", "127.0.0.1")
.set("index.search.elasticsearch.interface", "REST_CLIENT")
.open();
graph.addVertex("myLabel");
graph.tx().commit();
提交失败并出现以下错误:
09:41:53.297 [main] ERROR o.j.g.database.StandardJanusGraph - Could not commit transaction [1] due to exception
org.janusgraph.diskstorage.locking.TemporaryLockingException: Temporary locking failure
at org.janusgraph.diskstorage.locking.AbstractLocker.writeLock(AbstractLocker.java:309) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.diskstorage.locking.consistentkey.ExpectedValueCheckingStore.acquireLock(ExpectedValueCheckingStore.java:103) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.diskstorage.keycolumnvalue.KCVSProxy.acquireLock(KCVSProxy.java:52) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.diskstorage.BackendTransaction.acquireIndexLock(BackendTransaction.java:256) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.StandardJanusGraph.prepareCommit(StandardJanusGraph.java:572) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.StandardJanusGraph.commit(StandardJanusGraph.java:702) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.commit(StandardJanusGraphTx.java:1374) [janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsGraph$GraphTransaction.doCommit(JanusGraphBlueprintsGraph.java:272) [janusgraph-core-0.2.0.jar:na]
at org.apache.tinkerpop.gremlin.structure.util.AbstractTransaction.commit(AbstractTransaction.java:105) [gremlin-core-3.2.6.jar:3.2.6]
at engineering.divine.core.test.ConnectionTest.test(ConnectionTest.java:29) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50) [junit-4.12.jar:4.12]
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) [junit-4.12.jar:4.12]
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) [junit-4.12.jar:4.12]
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.access[=11=]0(ParentRunner.java:58) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) [.cp/:na]
Caused by: org.janusgraph.diskstorage.TemporaryBackendException: Lock write retry count exceeded
at org.janusgraph.diskstorage.locking.consistentkey.ConsistentKeyLocker.writeSingleLock(ConsistentKeyLocker.java:341) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.diskstorage.locking.consistentkey.ConsistentKeyLocker.writeSingleLock(ConsistentKeyLocker.java:125) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.diskstorage.locking.AbstractLocker.writeLock(AbstractLocker.java:304) ~[janusgraph-core-0.2.0.jar:na]
... 32 common frames omitted
如有任何错误提示,我将不胜感激。
我的本地计算机和 EC2 实例之间的网络延迟实际上太高,无法及时获取锁。将 storage.lock.wait-time
从 100 毫秒增加到 1 秒解决了这个问题。
我已经部署了 Cassandra 3.11.1 on an EC2 instance and connecting to it from my machine using the JanusGraph Java API。出于测试目的,该实例允许所有入站和出站 TCP 连接。
在 cassandra.yaml
文件中,我配置了如下值:
listen_address
: 私有 EC2 地址broadcast_address
: public EC2 地址seeds
: public EC2 地址start_rpc: true
rpc_address
: 私有 EC2 地址endpoint_snitch: Ec2MultiRegionSnitch
注意当我想使用publicEC2地址作为rpc_address
时,Cassandra启动失败这条消息:
Failed to bind port 9042 on <public EC2 address>
最后我尝试连接到图形,添加一个顶点并提交。
JanusGraph graph = JanusGraphFactory.build()
.set("storage.backend", "cassandra")
.set("storage.hostname", "<public EC2 address>")
.set("storage.cassandra.keyspace", "debug")
.set("storage.batch-loading", false)
.set("query.force-index", false)
.set("query.fast-property", true)
.set("cache.db-cache", true)
.set("schema.default", "default")
.set("index.search.backend", "elasticsearch")
.set("index.search.hostname", "127.0.0.1")
.set("index.search.elasticsearch.interface", "REST_CLIENT")
.open();
graph.addVertex("myLabel");
graph.tx().commit();
提交失败并出现以下错误:
09:41:53.297 [main] ERROR o.j.g.database.StandardJanusGraph - Could not commit transaction [1] due to exception
org.janusgraph.diskstorage.locking.TemporaryLockingException: Temporary locking failure
at org.janusgraph.diskstorage.locking.AbstractLocker.writeLock(AbstractLocker.java:309) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.diskstorage.locking.consistentkey.ExpectedValueCheckingStore.acquireLock(ExpectedValueCheckingStore.java:103) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.diskstorage.keycolumnvalue.KCVSProxy.acquireLock(KCVSProxy.java:52) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.diskstorage.BackendTransaction.acquireIndexLock(BackendTransaction.java:256) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.StandardJanusGraph.prepareCommit(StandardJanusGraph.java:572) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.StandardJanusGraph.commit(StandardJanusGraph.java:702) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.commit(StandardJanusGraphTx.java:1374) [janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsGraph$GraphTransaction.doCommit(JanusGraphBlueprintsGraph.java:272) [janusgraph-core-0.2.0.jar:na]
at org.apache.tinkerpop.gremlin.structure.util.AbstractTransaction.commit(AbstractTransaction.java:105) [gremlin-core-3.2.6.jar:3.2.6]
at engineering.divine.core.test.ConnectionTest.test(ConnectionTest.java:29) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50) [junit-4.12.jar:4.12]
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) [junit-4.12.jar:4.12]
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) [junit-4.12.jar:4.12]
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.access[=11=]0(ParentRunner.java:58) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) [.cp/:na]
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) [.cp/:na]
Caused by: org.janusgraph.diskstorage.TemporaryBackendException: Lock write retry count exceeded
at org.janusgraph.diskstorage.locking.consistentkey.ConsistentKeyLocker.writeSingleLock(ConsistentKeyLocker.java:341) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.diskstorage.locking.consistentkey.ConsistentKeyLocker.writeSingleLock(ConsistentKeyLocker.java:125) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.diskstorage.locking.AbstractLocker.writeLock(AbstractLocker.java:304) ~[janusgraph-core-0.2.0.jar:na]
... 32 common frames omitted
如有任何错误提示,我将不胜感激。
我的本地计算机和 EC2 实例之间的网络延迟实际上太高,无法及时获取锁。将 storage.lock.wait-time
从 100 毫秒增加到 1 秒解决了这个问题。