databendlabs / databend-jdbc

jdbc implementation for databend cloud
Apache License 2.0
10 stars 10 forks source link

feat: handle the X-Databend-Route-Hint header returned from the server side #280

Closed flaneur2020 closed 1 day ago

flaneur2020 commented 2 days ago

on some cases, the server will response a X-Databend-Route-Hint header in the response.

when server responded this header, the client should forget its own generated rout-hint, and remember the route-hint returned from the server.

this header is useful to keep the client session sticky on the same cluster when there're multiple clusters in the server side.

it seems that the jdbc driver still haven't processed this header from the server response yet.

may reference the logic in the go driver: https://github.com/databendlabs/databend-go/blob/main/client.go#L500

hantmac commented 2 days ago

Hi @flaneur2020 , the jdbc has handle the logic as same as go driver, maybe you can check here: https://github.com/databendlabs/databend-jdbc/blob/main/databend-client/src/main/java/com/databend/client/DatabendClientV1.java#L312

TCeason commented 2 days ago

If so maybe we can delete this?

https://github.com/datafuselabs/databend-jdbc/blob/bab24f4cc34b741513497620f041ae1b9b2c3e44/databend-jdbc/src/main/java/com/databend/jdbc/ConnectionProperties.java#L254

private static class RouteHint
            extends AbstractConnectionProperty<String> {
        public RouteHint() {
            super("route_hint", NOT_REQUIRED, ALLOWED, STRING_CONVERTER);
        }
    }

It's no usage.

flaneur2020 commented 1 day ago

If so maybe we can delete this?

https://github.com/datafuselabs/databend-jdbc/blob/bab24f4cc34b741513497620f041ae1b9b2c3e44/databend-jdbc/src/main/java/com/databend/jdbc/ConnectionProperties.java#L254

private static class RouteHint
            extends AbstractConnectionProperty<String> {
        public RouteHint() {
            super("route_hint", NOT_REQUIRED, ALLOWED, STRING_CONVERTER);
        }
    }

It's no usage.

if the code is not being referenced, i guess it's good to clean it up 🤔

flaneur2020 commented 1 day ago

Hi @flaneur2020 , the jdbc has handle the logic as same as go driver, maybe you can check here: https://github.com/databendlabs/databend-jdbc/blob/main/databend-client/src/main/java/com/databend/client/DatabendClientV1.java#L312

thank you for clarifying this, i believe the behaviour is aligned with the go-driver.

here the implmenetation stores the it in additionalHeaders, while the go-driver stores it inside a field of the client struct. the final behaviour should be the same.

hantmac commented 1 day ago

@TCeason https://github.com/databendlabs/databend-jdbc/pull/281 this pr clean up it, I will close this issue.