Skip to content

Commit cc3c50b

Browse files
committed
Resolve comment about database locking
I don't remember what I was thinking at the time. It looks like the transaction is stored in IssueData, so the lock should persist.
1 parent b378456 commit cc3c50b

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/handlers/merge_conflict.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
//!
1212
//! In general, multiple pushes happening quickly should be rare. And when it
1313
//! does happen, hopefully the state in the database will prevent duplicate
14-
//! messages. However, the database check itself is racey without a lock (see
15-
//! `maybe_add_comment`).
14+
//! messages.
1615
1716
use crate::{
1817
config::MergeConflictConfig,
@@ -262,11 +261,6 @@ async fn maybe_add_comment(
262261
issue: &Issue,
263262
possibly: Option<&str>,
264263
) -> anyhow::Result<()> {
265-
// Note: This database access is racey. Preferably there would be a
266-
// row-lock held between the time it is loaded and the save call below.
267-
// The `post_comment` call should normally be pretty fast, so races should
268-
// be rare. If they happen too often, consider adding some locking
269-
// mechanism here.
270264
let mut state: IssueData<'_, MergeConflictState> =
271265
IssueData::load(db, issue, MERGE_CONFLICT_KEY).await?;
272266
if state.data.last_warned_comment.is_some() {

0 commit comments

Comments
 (0)