diff --git a/src/api/posts/rebuild.rs b/src/api/posts/rebuild.rs index 5ba7b45..169092d 100644 --- a/src/api/posts/rebuild.rs +++ b/src/api/posts/rebuild.rs @@ -35,26 +35,29 @@ pub async fn rebuild_content_html(rebuild_all: bool) -> Result = Vec::new(); - // 整批 UPDATE 纳入单事务:中途断连或写入失败整批回滚,避免产生 - // 「部分文章已重建」的中间态(M5)。 + // 整批 SELECT + UPDATE 纳入单事务:中途断连或写入失败整批回滚,避免产生 + // 「部分文章已重建」的中间态(M5);FOR UPDATE 锁住的行随事务结束释放。 let tx = client.transaction().await.map_err(AppError::query)?; + let rows = tx.query(&query, &[]).await.map_err(AppError::query)?; + for row in &rows { let id: i32 = row.get(0); let content_md: String = row.get(1);