awslabs/pgbouncer-fast-switchover

Query rewrite should handle newer postgres JDBC connection validation types

darapuk opened this issue · 2 comments

Ran into a bug where(I'm guessing) Looker uses a newer version of a postgres JDBC driver than what pgbouncer-rr was originally tested with. The connection authentication seems to be using the below code to validate that a connection is valid.
https://github.com/pgjdbc/pgjdbc/blob/a4f8c9ecfe0cf8f162f49bdfd8db5ff0baedb233/org/postgresql/jdbc4/AbstractJdbc4Connection.java#L141

However, this validation check fails when the query re-write function intercepts the call because empty strings are being tagged with the rewrite tag.

The solution for this is to handle this in the re-write function by returning None when an empty string is detected by the query rewriter, or to handle this in the C code here: https://github.com/awslabs/pgbouncer-rr-patch/blob/c690d89c8f38544b6541d8cbaf13b6e8bef33853/src/rewrite_query.c#L89

def rewrite_query(username, query):
    if not query:
        return None
    ...

as an example of what you can do in the rewrite_query to handle this edge case

yahavb commented

makes sense. Will you be willing to help with that?