Skip to content

Commit

Permalink
fix(udf): use a dedicated runtime to create udf flight client (#18461)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzl25 authored Sep 13, 2024
1 parent bc9c2ad commit f226e21
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/expr/impl/src/udf/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use ginepro::{LoadBalancedChannel, ResolutionStrategy};
use risingwave_common::array::arrow::{ToArrow, UdfArrowConvert};
use risingwave_common::util::addr::HostAddr;
use thiserror_ext::AsReport;
use tokio::runtime::Runtime;

use super::*;

Expand Down Expand Up @@ -174,9 +175,16 @@ fn get_or_create_flight_client(link: &str) -> Result<Arc<Client>> {
// reuse existing client
Ok(client)
} else {
static RUNTIME: LazyLock<Runtime> = LazyLock::new(|| {
tokio::runtime::Builder::new_multi_thread()
.thread_name("rw-udf")
.enable_all()
.build()
.expect("failed to build udf runtime")
});
// create new client
let client = Arc::new(tokio::task::block_in_place(|| {
tokio::runtime::Handle::current().block_on(async {
RUNTIME.block_on(async {
let channel = connect_tonic(link).await?;
Ok(Client::new(channel).await?) as Result<_>
})
Expand Down

0 comments on commit f226e21

Please sign in to comment.