From 2483303138af6192147286fe5fc2ac82c17cc0e3 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 11 Jan 2021 12:05:46 +0900 Subject: [PATCH] SearchActor waits for transaction commit --- plume-models/src/search/actor.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plume-models/src/search/actor.rs b/plume-models/src/search/actor.rs index bc70011d..49852a95 100644 --- a/plume-models/src/search/actor.rs +++ b/plume-models/src/search/actor.rs @@ -2,6 +2,8 @@ use super::Searcher; use crate::{db_conn::DbPool, posts::PostEvent, ACTOR_SYS, POST_CHAN}; use riker::actors::{Actor, ActorFactoryArgs, ActorRefFactory, Context, Sender, Subscribe, Tell}; use std::sync::Arc; +use std::thread::sleep; +use std::time::Duration; use tracing::error; pub struct SearchActor { @@ -33,6 +35,9 @@ impl Actor for SearchActor { fn recv(&mut self, _ctx: &Context, msg: Self::Msg, _sender: Sender) { use PostEvent::*; + // Wait for transaction commited + sleep(Duration::from_millis(500)); + match msg { PostPublished(post) => { let conn = self.conn.get();