Getting namespace already existing error in Singlestore while using recursive CTE in mutlti threaded environment.
I have a table in db that contains enitire tree data id, parent_id and name and the root node having parent_id values as zero. My Requirement is based on name i need flattened data till root (node --> Parent-->GrandParent ------ Root) By using CTE i'm able get the required data.
let me know the better approach as well for this
Below are the details Singlestore version 8.1.32 Variables allow_materialize_cte_with_union = TRUE materialize_ctes = AUTO
Table: AccountTree
Id | Parent_ID | Name |
---|---|---|
101 | 0 | A |
105 | 101 | B |
106 | 105 | BA |
107 | 105 | BB |
108 | 106 | C |
109 | 108 | D |
110 | 107 | E |
If input name is C then my required Output is
Id | Parent_ID | Name |
---|---|---|
101 | 0 | A |
105 | 101 | B |
106 | 105 | BA |
108 | 106 | C |
QUERY: With Recursive FlattenedTree as( Select id, parent_id from AccountTree where name in (‘C’) UNION ALL Select t.id, t.parent_id from AccountTree t JOIN FlattenedTree as ft on t.id = ft. parent_id ) Select distinct * from AccountTree at Join FlattenedTree ft on at.id = ft.id
With the help of recursive CTE able to get the above results, but whereas in multi-threaded environment I’m getting the below error. (Each thread will have a separate connection object.)
Exception: Out of 100 instances(Threads) i'm getting the below error on 2-5 instances.
SQLSTATE: 42S01 Leaf error (memsql url) Arrangement ‘iter_FlattenedTree_21’ already exists in namespace ‘msql_testenv_col’::’temp_1_244244_8’