Skip to content

Commit d205795

Browse files
sunng87mamcx
andauthored
feat: update pgwire to 0.34 and improve how we disable ssl (#3432)
# Description of Changes Hello team, I'm the original author of pgwire library. In this patch, I have some updates about spacetimedb's usage of pgwire library: - Updated pgwire library to 0.34, which includes a critical fix for busy loop on accepting new connection - This version will return error on no-op handlers, as requested by @mamcx - Update `StartupHandler` for `SslRequest`. `SslRequest` is handled in `process_socket` automatically before `StartupHandler` kicks in. So it's safe to remove the match branch. The framework will reject TLS negotiation automatically if no TLS support compiled - Updated feature flags. Add `no-default-features` so we will not pull TLS dependencies. # API and ABI breaking changes N/A # Expected complexity level and risk 1 # Testing Would be nice to verify if you have integration test on postgres interface. --------- Co-authored-by: Mario Montoya <[email protected]>
1 parent 0f0cb47 commit d205795

File tree

3 files changed

+11
-60
lines changed

3 files changed

+11
-60
lines changed

Cargo.lock

Lines changed: 8 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ paste = "1.0"
219219
percent-encoding = "2.3"
220220
petgraph = { version = "0.6.5", default-features = false }
221221
pin-project-lite = "0.2.9"
222-
pgwire = { version = "0.32", features = ["server-api"] }
222+
pgwire = { version = "0.34.1", default-features = false, features = ["server-api", "pg-ext-types"] }
223223
postgres-types = "0.2.5"
224224
pretty_assertions = { version = "1.4", features = ["unstable"] }
225225
proc-macro2 = "1.0"

crates/pg/src/pg_server.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ pub(crate) enum PgError {
4646
DatabaseNameRequired,
4747
#[error(transparent)]
4848
Pg(#[from] PgWireError),
49-
#[error("SSL is not supported by SpacetimeDB")]
50-
SSLNotSupported,
5149
#[error(transparent)]
5250
Other(#[from] anyhow::Error),
5351
}
@@ -150,7 +148,7 @@ struct PgSpacetimeDB<T> {
150148
}
151149

152150
impl<T: ControlStateReadAccess + ControlStateWriteAccess + NodeDelegate + Clone> PgSpacetimeDB<T> {
153-
async fn exe_sql<'a>(&self, query: String) -> PgWireResult<Vec<Response<'a>>> {
151+
async fn exe_sql(&self, query: String) -> PgWireResult<Vec<Response>> {
154152
let params = self.cached.lock().await.clone().unwrap();
155153
let db = SqlParams {
156154
name_or_identity: database::NameOrIdentity::Name(DatabaseName(params.database.clone())),
@@ -282,12 +280,6 @@ impl<T: Sync + Send + ControlStateReadAccess + ControlStateWriteAccess + NodeDel
282280
self.cached.lock().await.clone_from(&Some(metadata));
283281
finish_authentication(client, &self.parameter_provider).await?;
284282
}
285-
PgWireFrontendMessage::SslRequest(_) => {
286-
let err = PgError::SSLNotSupported;
287-
log::error!("{err}");
288-
let err = ErrorInfo::new("FATAL".to_owned(), "28P01".to_owned(), err.to_string());
289-
return close_client(client, err).await;
290-
}
291283
// The other messages are for features not supported by SpacetimeDB, that are rejected by the parser.
292284
_ => {
293285
unreachable!("Unsupported startup message: {message:?}");
@@ -301,7 +293,7 @@ impl<T: Sync + Send + ControlStateReadAccess + ControlStateWriteAccess + NodeDel
301293
impl<T: Sync + Send + ControlStateReadAccess + ControlStateWriteAccess + NodeDelegate + Clone> SimpleQueryHandler
302294
for PgSpacetimeDB<T>
303295
{
304-
async fn do_query<'a, C>(&self, _client: &mut C, query: &str) -> PgWireResult<Vec<Response<'a>>>
296+
async fn do_query<C>(&self, _client: &mut C, query: &str) -> PgWireResult<Vec<Response>>
305297
where
306298
C: ClientInfo + Unpin + Send + Sync,
307299
{

0 commit comments

Comments
 (0)