Skip to content

Commit e63ed13

Browse files
authored
Fix rollbacks with query parser disabled (#549)
1 parent 46e7142 commit e63ed13

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

pgdog/src/backend/pool/connection/binding.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,4 +395,20 @@ impl Binding {
395395
_ => false,
396396
}
397397
}
398+
399+
/// Number of connected shards.
400+
pub fn shards(&self) -> Result<usize, Error> {
401+
Ok(match self {
402+
Binding::Admin(_) => 1,
403+
Binding::Direct(Some(_)) => 1,
404+
Binding::MultiShard(ref servers, _) => {
405+
if servers.is_empty() {
406+
return Err(Error::NotConnected);
407+
} else {
408+
servers.len()
409+
}
410+
}
411+
_ => return Err(Error::NotConnected),
412+
})
413+
}
398414
}

pgdog/src/frontend/client/query_engine/query.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,13 @@ impl QueryEngine {
284284
context: &mut QueryEngineContext<'_>,
285285
route: &Route,
286286
) -> Result<bool, Error> {
287-
if context.in_error()
287+
let shards = if let Ok(shards) = self.backend.shards() {
288+
shards
289+
} else {
290+
return Ok(true);
291+
};
292+
if shards > 1 // This check only matters for cross-shard queries
293+
&& context.in_error()
288294
&& !context.rollback
289295
&& context.client_request.executable()
290296
&& !route.rollback_savepoint()

0 commit comments

Comments
 (0)