google / lovefield

Lovefield is a relational database for web apps. Written in JavaScript, works cross-browser. Provides SQL-like APIs that are fast, safe, and easy to use.
https://google.github.io/lovefield/
Apache License 2.0
6.81k stars 366 forks source link

Browser hang/crash with leftOuterJoin after updating to 2.1.3 #123

Closed jgraham closed 8 years ago

jgraham commented 8 years ago

So, I suspect the fix in #120 is responsible for a regression (or possibly for exposing a latent bug).

I have a tool that does a query like:

SELECT * FROM tests
LEFT OUTER JOIN test_results AS results_1 ON tests.id == results_1.test_id
LEFT OUTER JOIN test_results AS results_2 ON tests.id == results_2.test_id
JOIN runs AS run_1 ON results_1.run_id == run_1.id
JOIN runs AS run_2 ON results_2.run_id == run_1.id
WHERE results_1.status == "PASS"
ORDER BY tests.id

With this version of lovefield this query causes Firefox to hang and Chrome's content process to crash. Changing the joins to inner joins prevents the hang.

I can provide running code if that helps.

freshp86 commented 8 years ago

Hi. I suspect that this is a bug that is uncovered and not a regression. I just filed another uncovered leftOuterJoin bug at https://github.com/google/lovefield/issues/124, which might be the same root cause as your report here, although in my case it does not hang, it just throws an assertion error. Providing running code will help a lot, but I would wait until #120 is fixed, and check again if this issue is reproducible first.

freshp86 commented 8 years ago

@jgraham: Can you check if you can still reproduce after https://github.com/google/lovefield/commit/3ffbd6a553194d9b2f8df5205aed04c6c91d98b2? I believe that it might have fixed it. My theory of what was happening is that because the optimizer was failing to push down some SelectNodes towards the bottom of the query execution plan, a bunch of cross-products ended up in your final optimized plan. Because you are joining 5 tables, the cross-products took too long to calculate (and consumed too much memory) causing the browsers to hang/crash. Hoping that this is not happening anymore, but if it is, let us know.

jgraham commented 8 years ago

It seems to work with that fix. Thanks!