-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: implicit cross joins can cause OOM errors #7572
Copy link
Copy link
Closed
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.S-3-ux-surpriseIssue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
Description
select4.test from sqllogictest causes my server to be killed by the kernel's OOM killer. It tries a cross join with 6 arguments (FROM a,b,c,d,e,f), and the join first tries to generate millions of cross-product rows in memory.
There are three issues that participate into this problem, which will need separate solutions:
- the JOIN makes a copy of its right-side data source in memory; if the right-side data source was itself a JOIN, we'll have the copy that JOIN made of its own right operand, plus the copy by the outer JOIN. Ideally,
planNodeshould be extended with aClose()orPurge()interface to release allocated data structures in memory after they are not needed any more. - JOINs really ought to be optimized and the filter expressions on the outer SELECT should be pushed down the JOIN operands so that the operands return fewer rows.
- Really we should not allow queries to allocate all the system's memory.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.S-3-ux-surpriseIssue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.