Reorder commit and metadata count logic
Move `tx.commit()?` after counting metadata rows under the old lazy_pk to ensure accurate count before commit. This fixes a potential race or inconsistency where metadata might be updated after commit, leading to incorrect logging of remaining rows under lazy_pk.
This commit is contained in:
@@ -1137,17 +1137,17 @@ impl DB {
|
|||||||
return Err(Error::QueryReturnedNoRows);
|
return Err(Error::QueryReturnedNoRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.commit()?;
|
// Compter les métadonnées encore sous l'ancien lazy_pk avant le commit
|
||||||
|
let meta_under_lazy: i64 = tx
|
||||||
// Compter les métadonnées encore sous l'ancien lazy_pk (après migration de l'asset)
|
.query_row(
|
||||||
let meta_under_lazy: i64 = {
|
|
||||||
let conn = self.lock_conn("update_lazy_to_downloaded_meta_check");
|
|
||||||
conn.query_row(
|
|
||||||
"SELECT COUNT(*) FROM metadata WHERE pk = ?1",
|
"SELECT COUNT(*) FROM metadata WHERE pk = ?1",
|
||||||
[lazy_pk],
|
[lazy_pk],
|
||||||
|r| r.get(0),
|
|r| r.get(0),
|
||||||
).unwrap_or(0)
|
)
|
||||||
};
|
.unwrap_or(0);
|
||||||
|
|
||||||
|
tx.commit()?;
|
||||||
|
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"update_lazy_to_downloaded: {} → {} ({} metadata rows still under lazy_pk)",
|
"update_lazy_to_downloaded: {} → {} ({} metadata rows still under lazy_pk)",
|
||||||
lazy_pk, real_pk, meta_under_lazy
|
lazy_pk, real_pk, meta_under_lazy
|
||||||
|
|||||||
Reference in New Issue
Block a user