Skip to content

Commit 0e514f9

Browse files
committed
v1.15.3
1 parent 9e27856 commit 0e514f9

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

klickhouse/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "klickhouse"
3-
version = "0.15.2"
3+
version = "0.15.3"
44
authors = ["Protryon <max.bruce12@gmail.com>"]
55
edition = "2024"
66
license = "MIT OR Apache-2.0"

klickhouse/src/migrate.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ pub struct ClusterMigration {
179179
client: Client,
180180
cluster_name: String,
181181
database: String,
182+
do_lock: bool,
182183
}
183184

184185
impl ClusterMigration {
@@ -187,8 +188,14 @@ impl ClusterMigration {
187188
client,
188189
cluster_name,
189190
database,
191+
do_lock: true,
190192
}
191193
}
194+
195+
pub fn without_lock(mut self) -> Self {
196+
self.do_lock = false;
197+
self
198+
}
192199
}
193200

194201
#[async_trait::async_trait]
@@ -201,15 +208,19 @@ impl AsyncTransaction for ClusterMigration {
201208
let lock = ClickhouseLock::new(self.client.clone(), "refinery_exec")
202209
.with_cluster(&self.cluster_name);
203210
let start = Instant::now();
204-
let handle = loop {
205-
if let Some(handle) = lock.try_lock().await? {
206-
break handle;
207-
} else {
208-
tokio::time::sleep(Duration::from_millis(250)).await;
209-
if start.elapsed() > Duration::from_secs(60) {
210-
lock.reset().await?;
211+
let handle = if self.do_lock {
212+
Some(loop {
213+
if let Some(handle) = lock.try_lock().await? {
214+
break handle;
215+
} else {
216+
tokio::time::sleep(Duration::from_millis(250)).await;
217+
if start.elapsed() > Duration::from_secs(60) {
218+
lock.reset().await?;
219+
}
211220
}
212-
}
221+
})
222+
} else {
223+
None
213224
};
214225
let mut n = 0;
215226
for query in queries {
@@ -224,7 +235,9 @@ impl AsyncTransaction for ClusterMigration {
224235
Client::execute(&self.client, query).await?;
225236
}
226237
}
227-
handle.unlock().await?;
238+
if let Some(handle) = handle {
239+
handle.unlock().await?;
240+
}
228241
Ok(n)
229242
}
230243
}

0 commit comments

Comments
 (0)