-
-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analyzer error: exceeded max analysis iterations (8)
#4816
Comments
I ran this repro and confirmed that without data in the tables, analysis completes successfully; when there is data inserted in the tables, analysis gets stuck in a loop and doesn't complete. Diffing the analyzer output for the two runs shows that the plans diverge during the Plan with no data in the tables: Project
├─ columns: [[U0.id, idx=6, type=char(32) COLLATE utf8mb4_0900_ai_ci, nullable=false]]
└─ Filter((([U1.lft, idx=9, type=int unsigned, nullable=false] >= [dcim_region.lft, idx=1, type=int unsigned, nullable=false]) AND ([U1.lft, idx=9, type=int unsigned, nullable=false] <= [dcim_region.rght, idx=2, type=int unsigned, nullable=false])) AND ([U1.tree_id, idx=11, type=int unsigned, nullable=false] = [dcim_region.tree_id, idx=3, type=int unsigned, nullable=false]))
└─ HashJoin([U0.region_id, idx=7, type=char(32) COLLATE utf8mb4_0900_ai_ci, nullable=true] = [U1.id, idx=8, type=char(32) COLLATE utf8mb4_0900_ai_ci, nullable=false]), comment=
├─ TableAlias(U0)
│ └─ Table
│ └─ columns: [id region_id]
└─ HashLookup(child: TUPLE([U1.id, idx=6, type=char(32) COLLATE utf8mb4_0900_ai_ci, nullable=false]), lookup: TUPLE([U0.region_id, idx=7, type=char(32) COLLATE utf8mb4_0900_ai_ci, nullable=true]))
└─ CachedResults
└─ TableAlias(U1)
└─ Table
└─ columns: [id lft rght tree_id] Plan with data in the tables: Project
├─ columns: [[U0.id, idx=6, type=char(32) COLLATE utf8mb4_0900_ai_ci, nullable=false]]
└─ Filter((([U1.lft, idx=9, type=int unsigned, nullable=false] >= [dcim_region.lft, idx=1, type=int unsigned, nullable=false]) AND ([U1.lft, idx=9, type=int unsigned, nullable=false] <= [dcim_region.rght, idx=2, type=int unsigned, nullable=false])) AND ([U1.tree_id, idx=11, type=int unsigned, nullable=false] = [dcim_region.tree_id, idx=3, type=int unsigned, nullable=false]))
└─ InnerJoin([U0.region_id, idx=11, type=char(32) COLLATE utf8mb4_0900_ai_ci, nullable=true] = [U1.id, idx=6, type=char(32) COLLATE utf8mb4_0900_ai_ci, nullable=false]), comment=
├─ TableAlias(U1)
│ └─ Table
│ └─ columns: [id lft rght tree_id]
└─ TableAlias(U0)
└─ Table
└─ columns: [id region_id] I'll continue digging in... |
During join planning, the cost of the tables is slightly different depending on if they contain rows or not. Having data in the table triggers an InnerJoin instead of a HashLookup to be used. InnerJoin is commutative, so on the next round of analysis, the expression group contains both orderings. The plan with the left/right sides reversed is chosen because it appears in the expression list first and has an identical cost to the non-flipped plan. This repeats on the next analysis cycle and causes the analyzer to error out since it can't find a stable plan. I've got a fix coded up to ensure we list the non-flipped plan first in the expression group and this query is now working. I'll get it cleaned up, add some more tests, and get a PR out shortly. |
repro:
The text was updated successfully, but these errors were encountered: