garlik/4store — Issue #48: query-backend.c fs_bind issues
Author: msalvadores
Created: 2011-12-06 02:13:20+00:00
State: open

This is related to the bug that I tried to fix last week. I could not fix it then but now I think I have found some related 'holes' in the query-backend.c fs_bind function.

fs_bind unique and sorting of rids
--------------------------------------------

The sorting and unique operation here

https://github.com/garlik/4store/blob/master/src/backend/query-backend.c#L184

is inconsistent with the pair index traversing that we do here ...

https://github.com/garlik/4store/blob/master/src/backend/query-backend.c#L410

and here ...

https://github.com/garlik/4store/blob/master/src/backend/query-backend.c#L470

We cannot sort and unique the rids vector if later on we are going to traverse by pairs.

Potential fix for this error

https://github.com/ncbo/4store/blob/ncbo_integration_branch/src/backend/query-backend.c#L186
(do not run sort/uniq when doing pair traversing)

fsp_bind_limit_many
-----------------------------

Another potential issue is in fsp_bind_limit_many where subjects are just sent to adequate segments. See

https://github.com/garlik/4store/blob/master/src/common/4s-client.c#L1491

If the backend branch receptor of the bind is either this one ...

https://github.com/garlik/4store/blob/master/src/backend/query-backend.c#L410

or this one

https://github.com/garlik/4store/blob/master/src/backend/query-backend.c#L470

then we can have a potential binding error. Search is again by pairs but we did not take that into account when filtering subjects by segments in 4s-client.c

Potential fix for this issue:
https://github.com/ncbo/4store/blob/ncbo_integration_branch/src/common/4s-client.c#L1506
(aligned the memcpy for predicates with subjects)

This is a tricky one, I do not really know how to address the other CASE branch.