Skip to content

Commit 2ce7566

Browse files
committed
store: Warn when background writer hasn't stopped yet
1 parent 400c24d commit 2ce7566

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

store/postgres/src/writable.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -1318,9 +1318,22 @@ impl WritableStoreTrait for WritableStore {
13181318

13191319
async fn restart(self: Arc<Self>) -> Result<Option<Arc<dyn WritableStoreTrait>>, StoreError> {
13201320
if self.poisoned() {
1321+
// When the writer is poisoned, the background thread has
1322+
// finished since `start_writer` returns whenever it encounters
1323+
// an error. Just to make extra-sure, we log a warning if the
1324+
// join handle indicates that the writer hasn't stopped yet.
13211325
let logger = self.store.logger.clone();
1322-
if let Err(e) = self.stop().await {
1323-
warn!(logger, "Writable had error when stopping, it is safe to ignore this error"; "error" => e.to_string());
1326+
match &self.writer {
1327+
Writer::Sync(_) => { /* can't happen, a sync writer never gets poisoned */ }
1328+
Writer::Async { join_handle, queue } => {
1329+
let err = match queue.check_err() {
1330+
Ok(()) => "error missing".to_string(),
1331+
Err(e) => e.to_string(),
1332+
};
1333+
if !join_handle.is_finished() {
1334+
warn!(logger, "Writer was poisoned, but background thread didn't finish. Creating new writer regardless"; "error" => err);
1335+
}
1336+
}
13241337
}
13251338
let store = Arc::new(self.store.store.0.clone());
13261339
store

0 commit comments

Comments
 (0)