Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vm-runner): Fix statement timeouts in VM playground #2772

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ impl WiringLayer for VmPlaygroundLayer {
// to DB for querying last processed batch and last ready to be loaded batch.
// - `window_size` connections for running VM instances.
let connection_pool = replica_pool
.get_custom(2 + self.config.window_size.get())
.build(|builder| {
builder
.set_max_size(2 + self.config.window_size.get())
.set_statement_timeout(None);
// Unlike virtually all other replica pool uses, VM playground has some long-living operations,
// so the default statement timeout would only get in the way.
})
.await?;

let cursor = VmPlaygroundCursorOptions {
Expand Down
15 changes: 14 additions & 1 deletion core/node/node_framework/src/implementations/resources/pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,20 @@ impl<P: PoolKind> PoolResource<P> {
}

pub async fn get_custom(&self, size: u32) -> anyhow::Result<ConnectionPool<P::DbMarker>> {
let result = self.builder().set_max_size(size).build().await;
self.build(|builder| {
builder.set_max_size(size);
})
.await
}

pub async fn build<F>(&self, build_fn: F) -> anyhow::Result<ConnectionPool<P::DbMarker>>
where
F: FnOnce(&mut ConnectionPoolBuilder<P::DbMarker>),
{
let mut builder = self.builder();
build_fn(&mut builder);
let size = builder.max_size();
let result = builder.build().await;

if result.is_ok() {
let old_count = self.connections_count.fetch_add(size, Ordering::Relaxed);
Expand Down
Loading