记一次 rr 和硬件断点解决内存踩踏问题
Posted NebulaGraph
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了记一次 rr 和硬件断点解决内存踩踏问题相关的知识,希望对你有一定的参考价值。
借助 rr 来定位查询语句结果不一致的问题。
在日常的调试过程中,我们总会遇到一些有趣的 bug,在本文我就遇到了一个有意思的查询结果不一致问题。
故事的开始
我们在测试 NebulaGraph 的 MATCH
语句的时候发现一个很神奇的事情:
(root@nebula) [gdlancer]> match (v1)-[e*1..1]->(v2) where id(v1) in [1, 2, 3, 4] and (v2)-[e*1..1]->(v1) return e;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| e |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [[:Rel_5 2->2 @0 Rel_5_0_Bool: true, Rel_5_1_Bool: true, Rel_5_2_Double: 0.533698, Rel_5_3_String: "Stephen Curry", Rel_5_4_Double: 0.162998]] |
| [[:Rel_1 2->2 @0 Rel_1_0_Int: 3, Rel_1_1_Int: 5, Rel_1_2_Int: 81, Rel_1_3_Double: 0.975062, Rel_1_4_Bool: true, Rel_1_5_Int: 59]] |
| [[:Rel_0 2->2 @0 Rel_0_0_Bool: true, Rel_0_1_String: "Kevin Durant", Rel_0_2_String: "Joel Embiid", Rel_0_3_Int: 96, Rel_0_4_Double: 0.468568, Rel_0_5_Int: 98, Rel_0_6_Int: 77]] |
| [[:Rel_2 2->2 @0 Rel_2_0_Int: 38, Rel_2_1_Double: 0.120953, Rel_2_2_String: "Null1", Rel_2_3_Bool: false, Rel_2_4_Bool: true, Rel_2_5_Int: 6, Rel_2_6_String: "Tracy McGrady"]] |
| [[:Rel_3 2->2 @0 Rel_3_0_String: "Aron Baynes", Rel_3_1_String: "LeBron James", Rel_3_2_Double: 0.831096, Rel_3_3_Int: 11]] |
| [[:Rel_4 2->2 @0 Rel_4_0_Bool: true, Rel_4_1_String: "Kevin Durant", Rel_4_2_Double: 0.71757, Rel_4_3_String: "Marc Gasol", Rel_4_4_Double: 0.285247, Rel_4_5_String: "Cory Joseph"]] |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Got 6 rows (time spent 146.7ms/168.31625ms)
Tue, 03 Jan 2023 14:10:03 CST
(root@nebula) [gdlancer]> match (v1)-[e*1..1]->(v2) where id(v1) in [1, 2, 3, 4] and (v2)-[e*1..1]->(v1) return e;
+---+
| e |
+---+
+---+
Empty set (time spent 30.67ms/58.220042ms)
Tue, 03 Jan 2023 14:10:05 CST
同样的语句,两次查询的结果集居然不一样!
开始 Debug
profile 出问题的语句:
(root@nebula) [gdlancer]> profile match (v1)-[e*1..1]->(v2) where id(v1) in [1, 2, 3, 4] and (v2)-[e*1..1]->(v1) return e;
+---+
| e |
+---+
+---+
Empty set (time spent 18.755ms/79.84375ms)
Execution Plan (optimize time 1656 us)
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| id | name | dependencies | profiling data | operator info |
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| 12 | Project | 11 | ver: 0, rows: 0, execTime: 17us, totalTime: 19us | outputVar: |
| | | | | "colNames": [ |
| | | | | "e" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Project_12" |
| | | | | |
| | | | | inputVar: __Filter_11 |
| | | | | columns: [ |
| | | | | "$e" |
| | | | | ] |
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| 11 | Filter | 10 | ver: 0, rows: 0, execTime: 26us, totalTime: 29us | outputVar: |
| | | | | "colNames": [ |
| | | | | "v1", |
| | | | | "e", |
| | | | | "v2" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Filter_11" |
| | | | | |
| | | | | inputVar: __PatternApply_10 |
| | | | | condition: ((id($v1)==1) OR (id($v1)==2) OR (id($v1)==3) OR (id($v1)==4)) |
| | | | | isStable: false |
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| 10 | PatternApply | 6,9 | ver: 0, rows: 0, execTime: 84us, totalTime: 87us | outputVar: |
| | | | | "colNames": [ |
| | | | | "v1", |
| | | | | "e", |
| | | | | "v2" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__PatternApply_10" |
| | | | | |
| | | | | inputVar: |
| | | | | "rightVar": "__AppendVertices_9", |
| | | | | "leftVar": "__Project_6" |
| | | | | |
| | | | | keyCols: [ |
| | | | | "id($-.v2)", |
| | | | | "id($-.v1)" |
| | | | | ] |
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| 6 | Project | 5 | ver: 0, rows: 18, execTime: 103us, totalTime: 106us | outputVar: |
| | | | | "colNames": [ |
| | | | | "v1", |
| | | | | "e", |
| | | | | "v2" |
| | | | | ], |
| | | | | "name": "__Project_6", |
| | | | | "type": "DATASET" |
| | | | | |
| | | | | inputVar: __AppendVertices_5 |
| | | | | columns: [ |
| | | | | "$-.v1 AS v1", |
| | | | | "[__VAR_2 IN $-.e WHERE is_edge($__VAR_2)] AS e", |
| | | | | "$-.v2 AS v2" |
| | | | | ] |
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| 5 | AppendVertices | 4 | | outputVar: |
| | | | ver: 0, rows: 18, execTime: 438us, totalTime: 1613us | "colNames": [ |
| | | | resp[2]: | "v1", |
| | | | "exec": "308(us)", | "e", |
| | | | "host": "store1:9779", | "v2" |
| | | | "total": "1114(us)" | ], |
| | | | | "name": "__AppendVertices_5", |
| | | | total_rpc: 1350(us) | "type": "DATASET" |
| | | | resp[0]: | |
| | | | "exec": "356(us)", | inputVar: __Traverse_4 |
| | | | "host": "store3:9779", | space: 8 |
| | | | "total": "1248(us)" | dedup: true |
| | | | | limit: -1 |
| | | | resp[1]: | filter: |
| | | | "exec": "323(us)", | orderBy: [] |
| | | | "host": "store2:9779", | src: none_direct_dst($-.e) |
| | | | "total": "966(us)" | props: [ |
| | | | | |
| | | | | "tagId": 13, |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ] |
| | | | | , |
| | | | | |
| | | | | "tagId": 12, |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ] |
| | | | | , |
| | | | | |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ], |
| | | | | "tagId": 11 |
| | | | | , |
| | | | | |
| | | | | "tagId": 9, |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ] |
| | | | | , |
| | | | | |
| | | | | "tagId": 10, |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ] |
| | | | | , |
| | | | | |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ], |
| | | | | "tagId": 14 |
| | | | | , |
| | | | | |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ], |
| | | | | "tagId": 15 |
| | | | | |
| | | | | ] |
| | | | | exprs: |
| | | | | vertex_filter: |
| | | | | if_track_previous_path: true |
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| 4 | Traverse | 2 | | outputVar: |
| | | | ver: 0, rows: 18, execTime: 597us, totalTime: 2943us | "colNames": [ |
| | | | step[1]: [ | "v1", |
| | | | | "e" |
| | | | "exec": "811(us)", | ], |
| | | | "host": "store2:9779", | "name": "__Traverse_4", |
| | | | "storage_detail": | "type": "DATASET" |
| | | | "GetNeighborsNode": "551(us)", | |
| | | | "HashJoinNode": "415(us)", | inputVar: __Dedup_2 |
| | | | "RelNode": "551(us)", | space: 8 |
| | | | "SingleEdgeNode": "391(us)" | dedup: true |
| | | | , | limit: -1 |
| | | | "total": "2139(us)", | filter: |
| | | | "total_rpc_time": "2328(us)", | orderBy: [] |
| | | | "vertices": 2 | src: $-._vid |
| | | | , | edgeTypes: [] |
| | | | | edgeDirection: OUT_EDGE |
| | | | "exec": "769(us)", | vertexProps: |
| | | | "host": "store1:9779", | edgeProps: [ |
| | | | "storage_detail": | |
| | | | "GetNeighborsNode": "259(us)", | "type": 21, |
| | | | "HashJoinNode": "177(us)", | "props": [ |
| | | | "RelNode": "259(us)", | "_src", |
| | | | "SingleEdgeNode": "161(us)" | "_type", |
| | | | , | "_rank", |
| | | | "total": "1938(us)", | "_dst", |
| | | | "total_rpc_time": "2328(us)", | "Rel_5_0_Bool", |
| | | | "vertices": 1 | "Rel_5_1_Bool", |
| | | | , | "Rel_5_4_Double", |
| | | | | "Rel_5_3_String", |
| | | | "exec": "699(us)", | "Rel_5_2_Double" |
| | | | "host": "store6:9779", | ] |
| | | | "storage_detail": | , |
| | | | "GetNeighborsNode": "161(us)", | |
| | | | "HashJoinNode": "152(us)", | "props": [ |
| | | | "RelNode": "162(us)", | "_src", |
| | | | "SingleEdgeNode": "142(us)" | "_type", |
| | | | , | "_rank", |
| | | | "total": "1735(us)", | "_dst", |
| | | | "total_rpc_time": "2328(us)", | "Rel_1_0_Int", |
| | | | "vertices": 1 | "Rel_1_3_Double", |
| | | | | "Rel_1_2_Int", |
| | | | ] | "Rel_1_4_Bool", |
| | | | | "Rel_1_5_Int", |
| | | | | "Rel_1_1_Int" |
| | | | | ], |
| | | | | "type": 17 |
| | | | | , |
| | | | | |
| | | | | "type": 16, |
| | | | | "props": [ |
| | | | | "_src", |
| | | | | "_type", |
| | | | | "_rank", |
| | | | | "_dst", |
| | | | | "Rel_0_6_Int", |
| | | | | "Rel_0_0_Bool", |
| | | | | "Rel_0_3_Int", |
| | | | | "Rel_0_2_String", |
| | | | | "Rel_0_4_Double", |
| | | | | "Rel_0_1_String", |
| | | | | "Rel_0_5_Int" |
| | | | | ] |
| | | | | , |
| | | | | |
| | | | | "type": 18, |
| | | | | "props": [ |
| | | | | "_src", |
| | | | | "_type", |
| | | | | "_rank", |
| | | | | "_dst", |
| | | | | "Rel_2_3_Bool", |
| | | | | "Rel_2_1_Double", |
| | | | | "Rel_2_4_Bool", |
| | | | | "Rel_2_5_Int", |
| | | | | "Rel_2_2_String", |
| | | | | "Rel_2_6_String", |
| | | | | "Rel_2_0_Int" |
| | | | | ] |
| | | | | , |
| | | | | |
| | | | | "type": 19, |
| | | | | "props": [ |
| | | | | "_src", |
| | | | | "_type", |
| | | | | "_rank", |
| | | | | "_dst", |
| | | | | "Rel_3_0_String", |
| | | | | "Rel_3_3_Int", |
| | | | | "Rel_3_1_String", |
| | | | | "Rel_3_2_Double" |
| | | | | ] |
| | | | | , |
| | | | | |
| | | | | "props": [ |
| | | | | "_src", |
| | | | | "_type", |
| | | | | "_rank", |
| | | | | "_dst", |
| | | | | "Rel_4_0_Bool", |
| | | | | "Rel_4_2_Double", |
| | | | | "Rel_4_5_String", |
| | | | | "Rel_4_1_String", |
| | | | | "Rel_4_4_Double", |
| | | | | "Rel_4_3_String" |
| | | | | ], |
| | | | | "type": 20 |
| | | | | |
| | | | | ] |
| | | | | statProps: |
| | | | | exprs: |
| | | | | random: false |
| | | | | steps: 1..1 |
| | | | | vertex filter: |
| | | | | edge filter: |
| | | | | if_track_previous_path: false |
| | | | | first step filter: |
| | | | | tag filter: |
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| 2 | Dedup | 1 | ver: 0, rows: 4, execTime: 16us, totalTime: 18us | outputVar: |
| | | | | "colNames": [ |
| | | | | "_vid" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Dedup_2" |
| | | | | |
| | | | | inputVar: __VAR_1 |
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| 1 | PassThrough | 3 | ver: 0, rows: 0, execTime: 14us, totalTime: 19us | outputVar: |
| | | | | "colNames": [ |
| | | | | "_vid" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__VAR_1" |
| | | | | |
| | | | | inputVar: |
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| 3 | Start | | ver: 0, rows: 0, execTime: 2us, totalTime: 29us | outputVar: |
| | | | | "colNames": [], |
| | | | | "type": "DATASET", |
| | | | | "name": "__Start_3" |
| | | | | |
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| 9 | AppendVertices | 8 | ver: 0, rows: 0, execTime: 46us, totalTime: 50us | outputVar: |
| | | | | "colNames": [ |
| | | | | "v2", |
| | | | | "e", |
| | | | | "v1" |
| | | | | ], |
| | | | | "type": "DATASET", |
| | | | | "name": "__AppendVertices_9" |
| | | | | |
| | | | | inputVar: __Traverse_8 |
| | | | | space: 8 |
| | | | | dedup: true |
| | | | | limit: -1 |
| | | | | filter: |
| | | | | orderBy: [] |
| | | | | src: none_direct_dst($-.e) |
| | | | | props: [ |
| | | | | |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ], |
| | | | | "tagId": 13 |
| | | | | , |
| | | | | |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ], |
| | | | | "tagId": 12 |
| | | | | , |
| | | | | |
| | | | | "tagId": 11, |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ] |
| | | | | , |
| | | | | |
| | | | | "tagId": 9, |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ] |
| | | | | , |
| | | | | |
| | | | | "tagId": 10, |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ] |
| | | | | , |
| | | | | |
| | | | | "tagId": 14, |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ] |
| | | | | , |
| | | | | |
| | | | | "tagId": 15, |
| | | | | "props": [ |
| | | | | "_tag" |
| | | | | ] |
| | | | | |
| | | | | ] |
| | | | | exprs: |
| | | | | vertex_filter: |
| | | | | if_track_previous_path: true |
-----+----------------+--------------+------------------------------------------------------+----------------------------------------------------------------------------
| 8 | Traverse | 7 | | outputVar: |
| | | | ver: 0, rows: 0, execTime: 4867us, totalTime: 9173us | "colNames": [ |
| | | | step[2]: [ | "v2", |
| | | | | "e" |
| | | | "exec": "488(us)", | ], |
| | | | "host": "store2:9779", | "type": "DATASET", |
| | | | "storage_detail": | "name": "__Traverse_8" |
| | | | "GetNeighborsNode": "371(us)", | |
| | | | "HashJoinNode": "261(us)", | inputVar: __Argument_7 |
| | | | "RelNode": "371(us)", | space: 8 |
| | | | "SingleEdgeNode": "243(us)" | dedup: true |
| | | | , | limit: -1 |
| | | | "total": "1509(us)", | filter: |
| | | | "total_rpc_time": "1948(us)", | orderBy: [] |
| | | | "vertices": 2 | src: id($-.v2) |
| | | | , | edgeTypes: [] |
| | | | | edgeDirection: OUT_EDGE |
| | | | "exec": "331(us)", | vertexProps: |
| | | | "host": "store3:9779", | edgeProps: [ |
| | | | "storage_detail": | |
| | | | "GetNeighborsNode": "86(us)", | "type": 21, |
| | | | "HashJoinNode": "63(us)", | "props": [ |
| | | | "RelNode": "86(us)", | "_src", |
| | | | "SingleEdgeNode": "54(us)" | "_type", |
| | | | , | "_rank", |
| | | | "total": "1208(us)", | "_dst", |
| | | | "total_rpc_time": "1948(us)", | "Rel_5_0_Bool", |
| | | | "vertices": 1 | "Rel_5_1_Bool", |
| | | | , | "Rel_5_4_Double", |
| | | | | "Rel_5_3_String", |
| | | | "exec": "686(us)", | "Rel_5_2_Double" |
| | | | "host": "store5:9779", | ] |
| | 以上是关于记一次 rr 和硬件断点解决内存踩踏问题的主要内容,如果未能解决你的问题,请参考以下文章