Thanks. What about rawdawg direct mode (No connection pooler)? Bad idea?
Thanks. What about rawdawg direct mode (No connection pooler)? Bad idea?

tokio-postgres crate) using the query method. This uses the extended query protocol. I am observing the following behavior. When the Hyperdrive cache is:UnexpectedMessage error). I suspect disabled caching makes Hyperdrive use one connection for preparation and another execution on another. Occasionally, it might use the same connection, leading to a successful query.query would always fail regardless of the cache setting. So, I started working on a PR for the Postgres driver to make it work with Hyperdrive. But today, during testing that PR, I saw this behavior, thus this question.






query instead of simple_query.simple_query intentionally.prepare twice (as in https://github.com/sfackler/rust-postgres/blob/98f5a11bc0a8e451552d8941ffa078c7eb6cd60c/tokio-postgres/src/to_statement.rs#L18, which is invoked from https://github.com/sfackler/rust-postgres/blob/98f5a11bc0a8e451552d8941ffa078c7eb6cd60c/tokio-postgres/src/client.rs#L363.query will be better (to be measured, of course). If not, my fork avoids an extra roundtrip.simple_query was required earlier (I believe until May 22 https://developers.cloudflare.com/hyperdrive/platform/changelog/#2024-05-22). With the prepared statement support in Hyperdrive, plain query also works with a caveat I mentioned (must turn on caching in Hyperdrive setting). The caveat is an issue in Hyperdrive (per @AJR), so once that is fixed, it will be all okay!
max-age is related to browser-side caching using HTTP headers. Hyperdrive has no ability to purge the browser-side cache so no.random() and ignoring that field in your result would do it.max-age. This is quite tricky to bust and you usually disable this for APIs in favor of 2.maxage, but if you want to only cache on the server-side you can use s-maxage instead.tokio-postgresqueryqueryqueryqueryqueryUnexpectedMessagesimple_querysimple_querysimple_querylet res1 = client.query("SELECT * FROM FOO", &[]).await?;
let res2 = client.query("SELECT * FROM FOO", &[]).await?;preparemax-agemax-agerandom()maxages-maxage