Skip to content

Commit 154fb55

Browse files
committed
Yield before your scheduler!
1 parent 165a331 commit 154fb55

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/syn2mas/src/migration.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use opentelemetry::KeyValue;
2121
use rand::{RngCore, SeedableRng};
2222
use thiserror::Error;
2323
use thiserror_ext::ContextInto;
24-
use tokio_util::sync::PollSender;
2524
use tracing::{Instrument as _, Level, info};
2625
use ulid::Ulid;
2726
use uuid::{NonNilUuid, Uuid};
@@ -275,6 +274,9 @@ async fn migrate_users(
275274
let mut password_buffer = MasWriteBuffer::new(&mas, MasWriter::write_passwords);
276275

277276
while let Ok(user) = rx.recv_async().await {
277+
// Force yielding to the scheduler, else we'll have long tick times
278+
tokio::task::yield_now().await;
279+
278280
// Handling an edge case: some AS users may have invalid localparts containing
279281
// extra `:` characters. These users are ignored and a warning is logged.
280282
if user.appservice_id.is_some()
@@ -616,6 +618,9 @@ async fn migrate_devices(
616618
let mut write_buffer = MasWriteBuffer::new(&mas, MasWriter::write_compat_sessions);
617619

618620
while let Ok(device) = rx.recv_async().await {
621+
// Force yielding to the scheduler, else we'll have long tick times
622+
tokio::task::yield_now().await;
623+
619624
let SynapseDevice {
620625
user_id: synapse_user_id,
621626
device_id,
@@ -769,6 +774,9 @@ async fn migrate_unrefreshable_access_tokens(
769774
MasWriteBuffer::new(&mas, MasWriter::write_compat_sessions);
770775

771776
while let Ok(token) = rx.recv_async().await {
777+
// Force yielding to the scheduler, else we'll have long tick times
778+
tokio::task::yield_now().await;
779+
772780
let SynapseAccessToken {
773781
user_id: synapse_user_id,
774782
device_id,

0 commit comments

Comments
 (0)