Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 15 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const GRPC_PORT = process.env.BLACKSMITH_STICKY_DISK_GRPC_PORT || '5557';
const MOUNT_BASE = '/blacksmith-git-mirror';
const MIRROR_VERSION = 'v1';
const REFRESH_TIMEOUT_SECS = 120; // 2 minutes
const GC_TIMEOUT_SECS = 60; // 60 seconds
const GC_TIMEOUT_SECS = 120; // 2 minutes
const FLUSH_TIMEOUT_SECS = 10; // 10 seconds for durability flush
const UMOUNT_TIMEOUT_SECS = 10; // 10 seconds for unmount
const UMOUNT_MAX_RETRIES = 3; // Number of unmount retry attempts
Expand Down Expand Up @@ -417,7 +417,20 @@ function runMirrorGC(mirrorPath_1) {
try {
// --auto: only run if thresholds exceeded (default: 6700 loose objects or 50 packs)
// This is much faster than a full gc when not needed
const result = yield exec.getExecOutput('timeout', [String(timeoutSecs), 'git', '-C', mirrorPath, 'gc', '--auto'], { ignoreReturnCode: true });
// gc.autoDetach=false: prevent git from forking a background daemon for GC.
// Without this, the parent `git gc --auto` returns immediately while the
// daemonized child keeps running with cwd and mmap'd pack files on the
// mirror mount, causing the subsequent `umount` to fail with EBUSY.
const result = yield exec.getExecOutput('timeout', [
String(timeoutSecs),
'git',
'-c',
'gc.autoDetach=false',
'-C',
mirrorPath,
'gc',
'--auto'
], { ignoreReturnCode: true });
if (result.exitCode === TIMEOUT_EXIT_CODE) {
core.warning(`[git-mirror] GC timed out after ${timeoutSecs}s`);
return {
Expand Down
17 changes: 15 additions & 2 deletions src/blacksmith-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const MOUNT_BASE = '/blacksmith-git-mirror'
const MIRROR_VERSION = 'v1'

const REFRESH_TIMEOUT_SECS = 120 // 2 minutes
const GC_TIMEOUT_SECS = 60 // 60 seconds
const GC_TIMEOUT_SECS = 120 // 2 minutes
const FLUSH_TIMEOUT_SECS = 10 // 10 seconds for durability flush
const UMOUNT_TIMEOUT_SECS = 10 // 10 seconds for unmount
const UMOUNT_MAX_RETRIES = 3 // Number of unmount retry attempts
Expand Down Expand Up @@ -479,9 +479,22 @@ async function runMirrorGC(
try {
// --auto: only run if thresholds exceeded (default: 6700 loose objects or 50 packs)
// This is much faster than a full gc when not needed
// gc.autoDetach=false: prevent git from forking a background daemon for GC.
// Without this, the parent `git gc --auto` returns immediately while the
// daemonized child keeps running with cwd and mmap'd pack files on the
// mirror mount, causing the subsequent `umount` to fail with EBUSY.
const result = await exec.getExecOutput(
'timeout',
[String(timeoutSecs), 'git', '-C', mirrorPath, 'gc', '--auto'],
[
String(timeoutSecs),
'git',
'-c',
'gc.autoDetach=false',
'-C',
mirrorPath,
'gc',
'--auto'
],
{ignoreReturnCode: true}
)
if (result.exitCode === TIMEOUT_EXIT_CODE) {
Expand Down
Loading