Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
7af3067
fix(node): close the advisory-lock probe's session if it is dropped m…
beardthelion Jul 29, 2026
edcf0f2
fix(node): add a dedicated, lazily-connected advisory-lock pool
beardthelion Jul 29, 2026
5ce3c7f
fix(node): hold the lock-owning connection in RepoWriteGuard (#279)
beardthelion Jul 29, 2026
c49d3cd
fix(node): free the advisory lock when a write guard dies without rel…
beardthelion Jul 29, 2026
98f2daf
fix(node): read the advisory unlock's result instead of discarding it
beardthelion Jul 29, 2026
9321d3b
fix(node): bound the object-storage transfers that run under the writ…
beardthelion Jul 29, 2026
9da0939
fix(node): authorize before taking the write lock in close_issue
beardthelion Jul 29, 2026
5d254fb
fix(node): address the review findings on the advisory-lock series
beardthelion Jul 30, 2026
d346bde
fix(node): log lock-pool saturation in the request path, not via read…
beardthelion Jul 30, 2026
82143ad
fix(node): refuse a write when object storage is unknowable, and shed…
beardthelion Jul 30, 2026
8cf6b7a
fix(node): re-authorize close_issue under the guard instead of only r…
beardthelion Jul 30, 2026
af5948b
style(node): rustfmt the new contention test
beardthelion Jul 30, 2026
e5558fb
fix(node): shed an unrefreshable write as a retryable 503 with a fixe…
beardthelion Aug 3, 2026
63a9ef8
fix(node): refuse a fresh-copy write when the archive HEAD cannot be …
beardthelion Aug 3, 2026
10230ac
fix(node): log expected transient acquire failures at warn, not error
beardthelion Aug 3, 2026
259d587
fix(node): log the read failure the close_issue pre-check folds into …
beardthelion Aug 3, 2026
999ee72
test(node): poll for the closed session instead of sleeping a fixed 3…
beardthelion Aug 3, 2026
5fdb902
fix(node): raise a failed fresh download with no local copy as RepoUn…
beardthelion Aug 9, 2026
f81ebbe
test(node): assert the second writer sheds as RepoBusy instead of tim…
beardthelion Aug 9, 2026
c4dbd8a
fix(node): read the close_issue author pre-check from a non-mutating …
beardthelion Aug 10, 2026
9f313b9
fix(node): bound every await in the lock-acquire loop by the deadline
beardthelion Aug 10, 2026
60d70c7
test(node): add an S3 mock that really enforces conditional writes
beardthelion Aug 10, 2026
31f90c4
fix(node): stop pretending a held lock fences a late upload
beardthelion Aug 10, 2026
3eabf79
feat(node): let the storage client express and detect a conditional w…
beardthelion Aug 10, 2026
317841e
fix(node): fence the release publish so an abandoned upload cannot win
beardthelion Aug 10, 2026
3d803ff
test(node): drive the abandoned-upload race end to end, and probe the…
beardthelion Aug 10, 2026
2a92a1f
fix(node): reconcile F-series tests and test seams with the rebased g…
beardthelion Aug 18, 2026
9f35dca
fix(node): address the 2026-08-10 review round on the advisory-lock s…
beardthelion Aug 18, 2026
9dd71e9
fix(node): record why the close-issue read gate cannot carry a synced…
beardthelion Aug 18, 2026
4cee7e0
merge origin/main into fix/279-advisory-lock-session-affinity
beardthelion Aug 26, 2026
b35cb31
fix(node): address jatmn review on merged advisory-lock head
beardthelion Aug 26, 2026
3c20148
fix(node): cap close_issue snapshot work on the read pool
beardthelion Aug 26, 2026
7ba0fef
fix(node): mark close_issue mirror visibility gate for push hook
beardthelion Aug 26, 2026
3df71c9
fix: unblock pre-push after main merge
beardthelion Aug 26, 2026
98fe670
fix(node): carry transient acquire failures through every write handler
beardthelion Aug 28, 2026
4f1c1bb
fix(node): drop unused logcap helper after drain_faults seam
beardthelion Aug 28, 2026
4eb0c44
fix(node): route fork disk paths through validated_repo_disk_path
beardthelion Aug 28, 2026
d1ce2e3
fix(node): harden release-upload outcomes and replication tail gating
beardthelion Aug 28, 2026
8e66e77
fix(node): close jatmn round on publish authority and durability gating
beardthelion Aug 29, 2026
1911291
fix(node): harden issue close/create and fork publish paths on #285
beardthelion Aug 29, 2026
5d3a4ea
fix(node): close write-attempt ownership gaps on advisory-lock release
beardthelion Aug 29, 2026
2ad2f12
fix(node): gate replication tail on publish durability and split clos…
beardthelion Aug 29, 2026
487687c
fix(node): add ValidatedRepoDiskPath for CodeQL and reconcile tail du…
beardthelion Aug 29, 2026
9d02139
fix(node): close three jatmn findings on advisory-lock PR
beardthelion Aug 30, 2026
85c6f48
fix(node): verify adversarial findings on advisory-lock PR
beardthelion Aug 30, 2026
5cd6703
fix(node): compensate under the write lock and harden tail durability…
beardthelion Aug 30, 2026
22da2d6
fix(node): refuse stale under-lock refresh and gate tail durability o…
beardthelion Aug 30, 2026
c306933
style(node): rustfmt advisory-lock gap-closure commits
beardthelion Aug 30, 2026
3a82ccb
fix(node): satisfy clippy on stale-local download test path join
beardthelion Aug 30, 2026
c40f299
feat(node): add a publish attempt/stage boundary
kevincodex1 Aug 31, 2026
21646bc
feat(node): stamp uploads with an attempt id and preserve dispatch am…
kevincodex1 Aug 31, 2026
5e548d2
fix(node): key durability, cache validity and fork cleanup on the att…
kevincodex1 Aug 31, 2026
535c5dc
fix(node): settle the cache contract on the abandoned path and the at…
beardthelion Sep 7, 2026
f048a1e
fix(node): settle the abandoned tree at the disconnect, not at reaper…
beardthelion Sep 7, 2026
957d50b
fix(node): let exactly one classifier settle an abandoned tree
beardthelion Sep 7, 2026
892c752
Merge origin/main into fix/279-advisory-lock-session-affinity
beardthelion Nov 4, 2026
28f3fc2
test(node): use the test's own pool now that Db::pool is gone
beardthelion Nov 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(node): shed an unrefreshable write as a retryable 503 with a fixe…
…d body

The two refusal arms added for the under-lock transfer bound returned bare
anyhow errors, so AppError's From impl (which downcasts only sqlx::Error and
RepoBusy) landed them in Internal: a 500 internal_error whose body was the
error string. Two defects in one. A transient object-storage failure told the
client not to retry, and the timeout arm's message interpolated the owner slug
and repo name straight into the response body, contradicting the fixed-body
policy the RepoBusy arm sets six lines above it.

RepoUnavailable follows RepoBusy exactly: a fieldless type raised with the
operator detail in a context string, downcast to its own rung, mapped to a 503
whose body interpolates nothing. The detail stays in the log at the raise site.

The timeout arm logs at error! where its sibling logs at warn!, deliberately: a
300s stall pinned a lock-pool slot for five minutes and is the condition the
transfer bound exists to surface, so it must keep paging when the handler
classifier demotes the ordinary blip case.
  • Loading branch information
beardthelion committed Aug 18, 2026
commit e5558fbb2784ba4a5bd890eb46d88c619f14420d
18 changes: 17 additions & 1 deletion crates/gitlawb-node/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ pub enum AppError {
#[error("repository is busy")]
RepoBusy,

#[error("repository is temporarily unavailable")]
RepoUnavailable,

#[error("database error: {0}")]
Db(#[from] sqlx::Error),

Expand Down Expand Up @@ -109,7 +112,13 @@ impl From<anyhow::Error> for AppError {
// site and the client gets a fixed retryable body.
Err(err) => match err.downcast::<crate::git::repo_store::RepoBusy>() {
Ok(_) => AppError::RepoBusy,
Err(err) => AppError::Internal(err),
// Same reasoning one rung down: a refused under-lock refresh is a
// transient storage condition, and its internal message names the
// owner slug and repo, so the variant carries nothing.
Err(err) => match err.downcast::<crate::git::repo_store::RepoUnavailable>() {
Ok(_) => AppError::RepoUnavailable,
Err(err) => AppError::Internal(err),
},
},
}
}
Expand Down Expand Up @@ -182,6 +191,13 @@ impl IntoResponse for AppError {
"repo_busy",
"repository is busy — retry".into(),
),
// 503 with a FIXED body for the same reason: the caller should retry, and
// must not be told which repo could not be refreshed or why.
AppError::RepoUnavailable => (
StatusCode::SERVICE_UNAVAILABLE,
"repo_unavailable",
"repository is temporarily unavailable, retry".into(),
),
AppError::Db(e) if db_unavailable(e) => (
StatusCode::SERVICE_UNAVAILABLE,
DB_UNAVAILABLE_CODE,
Expand Down
101 changes: 96 additions & 5 deletions crates/gitlawb-node/src/git/repo_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ impl RepoStore {
warn!(repo = %repo_name, err = %e,
"write acquire: tigris HEAD failed — refusing the write rather than \
guessing the archive is absent");
return Err(e).context("checking tigris for the repo archive before a write");
return Err(anyhow::Error::new(RepoUnavailable).context(format!(
"tigris HEAD failed before a write for {owner_slug}/{repo_name}"
)));
}
None => {
// TIMED OUT, which is NOT the same as failed, and must not reach
Expand All @@ -400,11 +402,23 @@ impl RepoStore {
//
// Refuse the acquire. Returning here drops the guard, whose Drop
// frees the lock and its pool slot.
return Err(anyhow::anyhow!(
"tigris refresh exceeded the {}s under-lock bound for {owner_slug}/{repo_name}; \
refusing the write rather than proceeding against a possibly-stale tree",
//
// `error!`, not the sibling `warn!` above, and that is deliberate.
// The handler layer demotes every `RepoUnavailable` to warn because
// the common cause is an ordinary storage blip. A stall that ran out
// the whole bound is not that: it pinned a lock-pool slot for the
// full duration, and this raise-site `error!` is what keeps it
// paging. Do NOT "fix" it to match the arm above.
tracing::error!(
repo = %repo_name,
owner = %owner_slug,
bound_secs = self.lock_held_transfer_timeout.as_secs(),
"under-lock tigris refresh exceeded the transfer bound, refusing the write"
);
return Err(anyhow::Error::new(RepoUnavailable).context(format!(
"tigris refresh exceeded the {}s under-lock bound for {owner_slug}/{repo_name}",
self.lock_held_transfer_timeout.as_secs()
));
)));
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
}
Expand Down Expand Up @@ -971,6 +985,24 @@ impl std::fmt::Display for RepoBusy {

impl std::error::Error for RepoBusy {}

/// The under-lock refresh could not establish what is in object storage, so the
/// write was refused rather than run against a possibly-stale tree.
///
/// A distinct type rather than a bare `anyhow` string so the handler layer can map
/// it to a retryable 503 with a FIXED body. The internal message names the owner
/// slug and repo, which must stay in the log at the raise site rather than reaching
/// the client.
#[derive(Debug)]
pub struct RepoUnavailable;

impl std::fmt::Display for RepoUnavailable {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("repository is temporarily unavailable")
}
}

impl std::error::Error for RepoUnavailable {}

/// Run a future under a wall-clock bound, returning `None` if it did not finish.
///
/// For the object-storage transfers that run while the per-repo advisory lock is
Expand Down Expand Up @@ -2708,6 +2740,65 @@ mod tests {
held.release(true).await;
}

/// An under-lock refresh refusal must surface as a retryable 503 with a fixed
/// body, not a 500 carrying the owner slug and repo name. Built directly from
/// the typed error so it needs no database; the `.context()` layer is kept
/// deliberately, because the real raise path wraps one and this proves anyhow
/// preserves downcastability through it.
#[tokio::test]
async fn repo_unavailable_maps_to_retryable_503_with_fixed_body() {
use axum::response::IntoResponse;

let err = anyhow::Error::new(RepoUnavailable)
.context("tigris HEAD failed before a write for did_key_z6MkTest/secret-repo");

let resp = crate::error::AppError::from(err).into_response();
assert_eq!(
resp.status(),
axum::http::StatusCode::SERVICE_UNAVAILABLE,
"a storage blip is transient and must be retryable, not a 500"
);
let body = axum::body::to_bytes(resp.into_body(), 64 * 1024)
.await
.expect("body");
let body = String::from_utf8_lossy(&body);
assert!(
body.contains("repo_unavailable"),
"the 503 must carry the repo_unavailable code, got {body}"
);
assert!(
!body.contains("secret-repo"),
"the 503 body must be fixed and must not name the repo, got {body}"
);
assert!(
!body.contains("did_key_z6MkTest"),
"the 503 body must be fixed and must not name the owner, got {body}"
);
}

/// The new downcast rung must be additive: an unrelated anyhow error still
/// falls through to the internal 500.
#[tokio::test]
async fn repo_unavailable_rung_does_not_swallow_unrelated_errors() {
use axum::response::IntoResponse;

let resp =
crate::error::AppError::from(anyhow::anyhow!("some other failure")).into_response();
assert_eq!(
resp.status(),
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
"an unrelated failure must not be reclassified as retryable"
);
let body = axum::body::to_bytes(resp.into_body(), 64 * 1024)
.await
.expect("body");
let body = String::from_utf8_lossy(&body);
assert!(
body.contains("internal_error"),
"an unrelated failure must keep the internal_error code, got {body}"
);
}

/// The transfer bound is a knob, so it gets the same parse/default/reject-zero
/// coverage its sibling lock-pool-size knob has.
#[test]
Expand Down