RedisGraph / redisgraph-go

A Golang client for redisgraph
https://redisgraph.io
BSD 3-Clause "New" or "Revised" License
132 stars 38 forks source link

[Bug] QueryResult parsing fails on node labels retrieval on read only replicas #74

Open marcinc opened 2 years ago

marcinc commented 2 years ago

I noticed an issue with the QueryResult -> parseRecords logic when running a query against a redis read-only replica. Specific issue around Labels retrieval that it called internally when parsing a node: https://github.com/RedisGraph/redisgraph-go/blob/3b0ad0971fcab5b4f4b74d28974e774cf938e290/query_result.go#L143 https://github.com/RedisGraph/redisgraph-go/blob/3b0ad0971fcab5b4f4b74d28974e774cf938e290/query_result.go#L178

Turned out the Labels() calls procedure internally https://github.com/RedisGraph/redisgraph-go/blob/3b0ad0971fcab5b4f4b74d28974e774cf938e290/graph.go#L283-L284 which disregards the mode for that procedure and always attempts to run RW g.Query(q) which will obviously fail on read-only replicas.

https://github.com/RedisGraph/redisgraph-go/blob/3b0ad0971fcab5b4f4b74d28974e774cf938e290/graph.go#L279

I'm happy to submit a PR for this issue as I've already solved it in my current project.