簡體   English   中英

Titan奇怪的一致性問題-具有相同邊緣ID的多個邊緣

[英]Titan strange consistency issues - Multiple edges with same edge id

我們在CentOs-7系統上使用來自datastax-ddc的 Titan 1.0.0Cassandra版本3.9.0-1 我們看到了一些奇怪的問題,例如:

  • 具有相同邊緣ID的多個邊緣,這些邊緣上的幾個屬性的值確實不同。

    gV()。has('msid',6171699).outE('prio_child')。has('hostid_e',153).as('e')inV()。has('msid',58713376).select( 'e')==> e [ 54ekdatm-1lezwb4-45cl-195s9km8 ] [3471761488-prio_child-> 98305011872] ==> e [ 54ekdatm-1lezwb4-45cl-195s9km8 ] [3471761488-prio_child-> 98305011872]

  • 施加更多限制后獲得更多結果

    gV()。has('msid',6171699).outE('prio_child')。count()
    ==> 60

    gV()。has('msid',6171699).outE('prio_child')。has('hostid_e,153).count()
    ==> 66

我什至嘗試設置ConsistencyModifier.LOCK,正如Titan文檔最終一致后端所建議的那樣,但是它沒有幫助。 我仍然得到任意結果。

Titan 1.0.0與Cassandra 3.x不兼容http://s3.thinkaurelius.com/docs/titan/1.0.0/version-compat.html

泰坦也不再得到維護。 JanusGraph http://janusgraph.org/已接替Titan離開的地方,並正在積極地進行更新和維護。

通過遵循Data Consistency ,我能夠復制並修復它。 設置ConsistencyModifier后,我錯過了以下命令。

mgmt.commit()

以下是重現問題的一段代碼,包括cassandra的兩個版本,即cassandra 2.1.x和cassandra3.9.x。

TitanGraph graph = TitanFactory.open("/opt/cmsgraph/config/edgepoc.conf");
    try {
        int parent = -2128958273;
        int child = 58541705;
        int hostid = 83;
        int numThreads = 100;
        Thread[] threads = new Thread[numThreads];
        for(int i =0; i < numThreads; i++) {
            threads[i] = new Thread(new EdgeUpdator(graph, parent, child, hostid));
        }
        for(int i =0; i < numThreads; i++) {
            threads[i].start();
        }
        for(int i = 0; i < numThreads; i++) {
            threads[i].join();
        }
    } finally {
        graph.close();
    }

    private static class EdgeUpdator implements Runnable {
        public EdgeUpdator(TitanGraph graph, int parent, int child, int hostid) {
            this.graph = graph;
            this.parent = parent;
            this.child = child;
            this.hostid = hostid;
        }

        private int parent;
        private int child;
        private int hostid;
        private TitanGraph graph;

        public void run() {
            TitanTransaction trxn = graph.newTransaction();
            GraphTraversalSource g = trxn.traversal();
            Edge edge = (Edge)g.V().has("msid", parent).outE("prio_child").has("hostid_e", hostid).as("e").inV().has("msid", child).select("e").next();
            Random random = new Random(System.nanoTime());
            edge.property("updatedAt_e", random.nextLong());
            edge.property("plrank", random.nextInt());
            trxn.commit();
        }
    }

在執行上面的代碼之前。 我懂了:

gremlin> g.V().has('msid', -2128958273).outE('prio_child').has('hostid_e', 83).as('e').inV().has('msid', 58541705).select('e')
    ==>e[239suvpz-17ofqw-41ed-9eutzq8][73363640-prio_child->20489355296]
    gremlin> g.V().has('msid', -2128958273).outE('prio_child').has('hostid_e', 83).as('e').inV().has('msid', 58541705).select('e').count()
    ==>1
    gremlin> g.V().has('msid', -2128958273).outE('prio_child').has('hostid_e', 83).count()
    ==>104

執行代碼后,我看到:

gremlin> g.V().has('msid', -2128958273).outE('prio_child').has('hostid_e', 83).as('e').inV().has('msid', 58541705).select('e')
    ==>e[239suvpz-17ofqw-41ed-9eutzq8][73363640-prio_child->20489355296]
    ==>e[239suvpz-17ofqw-41ed-9eutzq8][73363640-prio_child->20489355296]
    ==>e[239suvpz-17ofqw-41ed-9eutzq8][73363640-prio_child->20489355296]
    ==>e[239suvpz-17ofqw-41ed-9eutzq8][73363640-prio_child->20489355296]
    ==>e[239suvpz-17ofqw-41ed-9eutzq8][73363640-prio_child->20489355296]
    ==>e[239suvpz-17ofqw-41ed-9eutzq8][73363640-prio_child->20489355296]
    ==>e[239suvpz-17ofqw-41ed-9eutzq8][73363640-prio_child->20489355296]
    ==>e[239suvpz-17ofqw-41ed-9eutzq8][73363640-prio_child->20489355296]
    ==>e[239suvpz-17ofqw-41ed-9eutzq8][73363640-prio_child->20489355296]
    ==>e[239suvpz-17ofqw-41ed-9eutzq8][73363640-prio_child->20489355296]
    gremlin> g.V().has('msid', -2128958273).outE('prio_child').has('hostid_e', 83).as('e').inV().has('msid', 58541705).select('e').count()
    ==>10
    gremlin> g.V().has('msid', -2128958273).outE('prio_child').has('hostid_e', 83).as('e').inV().has('msid', 58541705).select('e').dedup().count()
    ==>1
    gremlin> g.V().has('msid', -2128958273).outE('prio_child').has('hostid_e', 83).count()
    ==>113
    gremlin> g.V().has('msid', -2128958273).outE('prio_child').count()
    ==>104

將ConsitencyModifier.LOCK應用於“ prio_child”邊緣后,我觀察到10個線程中有9個由於以下異常而失敗,並且我沒有導致具有相同邊緣id問題的多個邊緣。

Exception in thread "Thread-8" org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException

以下是我所做的確切更改:

mgmt = graph.openManagement()
    prio_child=mgmt.getRelationType('prio_child')
    mgmt.setConsistency(prio_child, ConsistencyModifier.LOCK)
    mgmt.commit()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM