EnterpriseDB / mysql_fdw

PostgreSQL foreign data wrapper for MySQL
Other
521 stars 160 forks source link

[Bug] infinite loop produced by mysqlGetForeignJoinPaths #224

Closed markrui3 closed 2 years ago

markrui3 commented 3 years ago

mysql_fdw with version >= 2_5_5 add GetForeignJoinPaths callback, which include a bug of infinite loop.

In this callback, function will be called in this way: mysqlGetForeignJoinPaths()->mysql_foreign_join_ok() And in mysql_foreign_join_ok, some wrong code are belows:

case JOIN_INNER:
    fpinfo->remote_conds = list_concat(fpinfo->remote_conds, fpinfo_i->remote_conds);
    fpinfo->remote_conds = list_concat(fpinfo->remote_conds, fpinfo_o->remote_conds);

In my case, it is very simple. We prepare three tables called tablea, tableb, tablec. They are referenced as tablea.aid=tableb.firstid and tablec.cid=tableb.secondid. Every table has only less than 100 rows. Full sql is:

explain select count(*) from tablea a inner join tableb b on a.aid=b.firstid inner join tablec c on c.cid=b.secondid where a.deleted=0 and b.deleted=0 and c.deleted=0;

When gdb attach the process, the code logic is like this: ListA:a1->b1 ListB:c1->b1 After list_concat, the result is a1->b1->c1->b1. When iterate this list, it will loop forever, like a1->b1->c1->b1->c1->b1->c1->b1..., finally cause OOM.

I think may be not use list_concat, append every element in list into another will be better.

jeevanchalke commented 3 years ago

We have fixed a bug in this area on Jun 9 with the commit id ba95a638bf2833adbde7925b24571d7f90537878.

Can you please re-verify this issue by pulling the latest source?

markrui3 commented 3 years ago

We have fixed a bug in this area on Jun 9 with the commit id ba95a63.

Can you please re-verify this issue by pulling the latest source?

Yeah, that fixed all. When will this commit get release?

jeevanchalke commented 2 years ago

This fix is available in the latest release. @markrui3 Please check and if you are OK, kind request to close this issue.

Thanks

surajkharage19 commented 2 years ago

Hi @markrui3,

We have not received further updates from you on this. Hoping that issue is resolved. We are closing the case for now. If the issue persists, you can reopen the case anytime.

markrui3 commented 2 years ago

Sorry for reply late, the commit is what I want, thank you