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): address jatmn review on merged advisory-lock head
Align .env.example db pool with validate floor, move snapshot cleanup into
the blocking extract task, remove fork clones on PreconditionLost, restore
upload_site_reached test plumbing, and use owner DIDs in receive-pack tests
after #330 owner-push default.
  • Loading branch information
beardthelion committed Aug 26, 2026
commit b35cb31944c97db70496698c0ce4bfc4e3003d43
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ DATABASE_URL=postgresql://gitlawb:changeme@localhost:5432/gitlawb
# Maximum connections in the PostgreSQL pool. A cap, not a floor —
# connections open lazily. Size against the DB server's max_connections,
# remembering admin tooling opens its own pool.
GITLAWB_DB_MAX_CONNECTIONS=20
GITLAWB_DB_MAX_CONNECTIONS=48
# Maximum connections in the DEDICATED advisory-lock pool, separate from the
# pool above. Every in-flight repo write pins one connection here for its whole
# duration, so this is a hard ceiling on simultaneous writes node-wide: size it
Expand Down
19 changes: 13 additions & 6 deletions crates/gitlawb-node/src/api/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3149,8 +3149,8 @@ pub async fn fork_repo(
// archive already sits under this key (a failed create_repo or another
// writer), and proceeding would create a DB record whose archive is shadowed
// by bytes that are not this fork. Refuse rather than accept a fork other
// nodes would fetch as unrelated content. The local clone is cleaned up on
// this path by the caller's error return dropping the handler state.
// nodes would fetch as unrelated content. Remove the local mirror clone so
// a refused fork does not leave a bare repo on disk.
state
.repo_store
.release_after_write(&forker_did, &fork_name)
Expand All @@ -3163,6 +3163,13 @@ pub async fn fork_repo(
status,
"fork refused: an archive already exists under the fork's key"
);
if let Err(clean) = std::fs::remove_dir_all(&disk_path) {
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
tracing::warn!(
path = %disk_path.display(),
err = %clean,
"failed to remove fork clone after precondition loss"
);
}
AppError::RepoExists(fork_name.clone())
}
other => AppError::Git(format!("fork upload failed: {other}")),
Expand Down Expand Up @@ -6402,7 +6409,7 @@ mod tests {
State(state.clone()),
Path((owner.to_string(), name.to_string())),
Extension(crate::auth::AuthenticatedDid(
"did:key:z6MkDisconnectWriteLockProofDidAAAAAAAA".to_string(),
"did:key:z6disc".to_string(),
)),
crate::rate_limit::PeerAddr(Some(
"203.0.113.81:5000".parse::<SocketAddr>().unwrap(),
Expand Down Expand Up @@ -6554,7 +6561,7 @@ mod tests {
State(state.clone()),
Path((owner.to_string(), name.to_string())),
Extension(crate::auth::AuthenticatedDid(
"did:key:z6MkPushSuccessReleaseProofDidAAAAAAAA".to_string(),
"did:key:z6succ".to_string(),
)),
crate::rate_limit::PeerAddr(Some(
"203.0.113.83:5000".parse::<SocketAddr>().unwrap(),
Expand Down Expand Up @@ -6630,7 +6637,7 @@ mod tests {
.await
.unwrap();

let did = "did:key:z6MkLockPoolShedProofDidAAAAAAAAAAAAAAAAAA";
let did = "did:key:z6lockpool";
let peer: SocketAddr = "203.0.113.71:5000".parse().unwrap();

// Occupy the only lock-pool connection with a write on an UNRELATED repo.
Expand All @@ -6657,7 +6664,7 @@ mod tests {

// MUST-NOT: with the pool free again, the push is not shed as capacity (it fails
// later on the nonexistent on-disk repo, which is a git error, not Overloaded).
held.release(false).await;
let _ = held.release(false).await;
let admitted = git_receive_pack(
State(state.clone()),
Path((owner.to_string(), name.to_string())),
Expand Down
26 changes: 26 additions & 0 deletions crates/gitlawb-node/src/git/repo_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ pub struct RepoStore {
/// `RepoWriteGuard::test_pre_unlock_gate`. Never set outside tests.
#[cfg(test)]
pre_unlock_gate: Option<Arc<tokio::sync::Notify>>,
/// Per store rather than a process global, so parallel tests do not see each
/// other's uploads. See [`RepoStore::tigris_upload_site_reached`].
#[cfg(test)]
upload_site_reached: Arc<std::sync::atomic::AtomicUsize>,
}

impl RepoStore {
Expand All @@ -60,6 +64,7 @@ impl RepoStore {
lock_acquire_deadline: LOCK_ACQUIRE_DEADLINE,
migrated: Arc::new(tokio::sync::Mutex::new(std::collections::HashSet::new())),
pre_unlock_gate: None,
upload_site_reached: Arc::new(std::sync::atomic::AtomicUsize::new(0)),
}
}

Expand Down Expand Up @@ -91,6 +96,14 @@ impl RepoStore {
self
}

/// Test-only: how many write guards from this store have reached the Tigris upload
/// site. See [`RepoWriteGuard::release`].
#[cfg(test)]
pub fn tigris_upload_site_reached(&self) -> usize {
self.upload_site_reached
.load(std::sync::atomic::Ordering::SeqCst)
}

pub fn new(
repos_dir: PathBuf,
tigris: Option<TigrisClient>,
Expand All @@ -106,6 +119,8 @@ impl RepoStore {
migrated: Arc::new(Mutex::new(HashSet::new())),
#[cfg(test)]
pre_unlock_gate: None,
#[cfg(test)]
upload_site_reached: Arc::new(std::sync::atomic::AtomicUsize::new(0)),
}
}

Expand Down Expand Up @@ -448,6 +463,8 @@ impl RepoStore {
publish_fence: UploadPrecondition::Unconditional,
#[cfg(test)]
test_pre_unlock_gate: self.pre_unlock_gate.clone(),
#[cfg(test)]
upload_site_reached: Arc::clone(&self.upload_site_reached),
};

// Always download the latest from Tigris before writing. Local disk may be
Expand Down Expand Up @@ -1040,6 +1057,8 @@ pub struct RepoWriteGuard {
/// frees the session lock. Never set outside tests.
#[cfg(test)]
test_pre_unlock_gate: Option<Arc<tokio::sync::Notify>>,
#[cfg(test)]
upload_site_reached: Arc<std::sync::atomic::AtomicUsize>,
}

impl RepoWriteGuard {
Expand Down Expand Up @@ -1150,6 +1169,9 @@ impl RepoWriteGuard {
let mut outcome = ReleaseOutcome::Released;
// Upload to Tigris only on success.
if success {
#[cfg(test)]
self.upload_site_reached
.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
if let Some(tigris) = self.tigris.clone() {
// ONE budget for the whole publish, covering both attempts and
// the HEAD between them, for the same reason the acquire-side
Expand Down Expand Up @@ -2489,6 +2511,8 @@ mod tests {
publish_fence: UploadPrecondition::Unconditional,
#[cfg(test)]
test_pre_unlock_gate: None,
#[cfg(test)]
upload_site_reached: Arc::new(std::sync::atomic::AtomicUsize::new(0)),
};
// Must complete without panic and issue no unlock.
let _ = guard.release(false).await;
Expand Down Expand Up @@ -2851,6 +2875,8 @@ mod tests {
publish_fence: UploadPrecondition::Unconditional,
#[cfg(test)]
test_pre_unlock_gate: None,
#[cfg(test)]
upload_site_reached: Arc::new(std::sync::atomic::AtomicUsize::new(0)),
};
let _ = guard.release(true).await;

Expand Down
62 changes: 30 additions & 32 deletions crates/gitlawb-node/src/git/tigris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,8 @@ impl TigrisClient {
.into_bytes();

// The snapshot temp dir is decided HERE, in the async layer, before the
// extraction runs. The extraction itself is uncancellable spawn_blocking,
// so the dir is created no matter what happens to this future; an
// async-layer guard that owns the path removes it when this future is
// dropped mid-await (client disconnect, a bounded-transfer timeout).
// extraction runs. Cleanup ownership moves into the blocking task so a
// cancelled async future cannot drop it while extraction is still running.
let snapshot_tmp = if publish {
None
} else {
Expand All @@ -289,48 +287,48 @@ impl TigrisClient {
uuid::Uuid::new_v4()
)))
};
// Armed before the extraction await; disarmed on the success return via
// `mem::forget`, leaving the dir to the caller (RepoSnapshot::drop). On
// any other exit, including a cancelled future, the guard removes the
// dir. This is what closes the leak where a dropped read_snapshot future
// abandons a completed extraction.
let _cleanup = snapshot_tmp.as_ref().map(|p| SnapshotCleanup(p.clone()));

// Extract tar.zst to a directory.
let extracted = tokio::task::spawn_blocking({
let target = target.to_path_buf();
let snapshot_tmp = snapshot_tmp.clone();
move || -> Result<PathBuf> {
if publish {
decompress_repo(&data, &target)?;
return Ok(target);
}
// Non-mutating snapshot: unpack into the temp dir decided above.
// The live repo path is never touched.
let tmp_dir = snapshot_tmp.expect("snapshot path was decided above");
std::fs::create_dir_all(&tmp_dir).context("creating temp extract dir")?;
let unpack = (|| -> Result<()> {
let decoder = zstd::stream::Decoder::new(&data[..])?;
let mut archive = tar::Archive::new(decoder);
archive.unpack(&tmp_dir).context("unpacking tar.zst")?;
Ok(())
// Armed for the whole blocking extraction; disarmed on success via
// `mem::forget`, leaving the dir to the caller (RepoSnapshot::drop).
let cleanup = snapshot_tmp.as_ref().map(|p| SnapshotCleanup(p.clone()));
let result = (|| -> Result<PathBuf> {
if publish {
decompress_repo(&data, &target)?;
return Ok(target);
}
// Non-mutating snapshot: unpack into the temp dir decided above.
// The live repo path is never touched.
let tmp_dir = snapshot_tmp.expect("snapshot path was decided above");
std::fs::create_dir_all(&tmp_dir).context("creating temp extract dir")?;
let unpack = (|| -> Result<()> {
let decoder = zstd::stream::Decoder::new(&data[..])?;
let mut archive = tar::Archive::new(decoder);
archive.unpack(&tmp_dir).context("unpacking tar.zst")?;
Ok(())
})();
if let Err(e) = unpack {
let _ = std::fs::remove_dir_all(&tmp_dir);
return Err(e);
}
Ok(tmp_dir)
})();
if let Err(e) = unpack {
let _ = std::fs::remove_dir_all(&tmp_dir);
return Err(e);
if result.is_ok() {
if let Some(guard) = cleanup {
std::mem::forget(guard);
}
}
Ok(tmp_dir)
result
}
})
.await
.context("extract task panicked")?
.context("extracting repo")?;

// The dir is now the caller's to own: drop the cleanup guard without
// removing anything. On a future drop before this point, `_cleanup` runs
// and removes the dir even though the extraction completed.
std::mem::forget(_cleanup);

info!(key = %key, path = %target.display(), "downloaded repo from tigris");
Ok(extracted)
}
Expand Down