# Deployment #5 (2026-10-10): pump_dead false-positive fix (DeviceWorker health check). # Why it regressed: PumpAlive is refreshed only on the owner thread's wait/dispatch tick (250ms # quantum), so it reads stale-false for up to one quantum AFTER a blocking SDK call returns. # A full-buffer read starves the pump for tens of seconds. The sequential health tick fires as # soon as read+persist ends. Before the ingest filter, persist took ~60s (owner had long since # resumed ticking -> fresh -> healthy). With Expired rows skipped at ingest, persist now lands # in <250ms -> health tick sees the STALE false -> tears down a healthy session every cycle # (observed: 12 pump_deads in the 11:00 hour on FULL-read devices, 0 in 09:00-11:21). # Fix: PumpConfirmedDeadAsync re-checks once after one pump quantum (500ms); a genuinely dead # pump stays false and is still recreated. No behaviour change for real stalls. $ErrorActionPreference = 'Continue' $outFile = "G:\WEB-SERVER\htdocs\AttendanceHub\ZKTecoSyncService-V2\_deployment\deploy_20261010_pumpfix_results.txt" $r = New-Object System.Collections.Generic.List[string] $r.Add("deployStart=$(Get-Date -Format o)") $r.Add("host=" + $env:COMPUTERNAME) # 0) Record DB state BEFORE so the effect is measurable $db = "G:\WEB-SERVER\htdocs\AttendanceHub\ZKTecoSyncService-V2\publish\attendancehub_v2.db" if (Test-Path $db) { $before = (Get-Item $db).Length $wal = if (Test-Path "$db-wal") { (Get-Item "$db-wal").Length } else { 0 } $r.Add("db_before_bytes=$before wal_before_bytes=$wal total=$($before + $wal)") } else { $r.Add("db_before: MISSING ($db)") } # 1) Stop service (graceful, then force) Stop-Service ZKTecoSyncService -Force -ErrorAction SilentlyContinue $sw = [System.Diagnostics.Stopwatch]::StartNew() while ((Get-Service ZKTecoSyncService).Status -ne 'Stopped' -and $sw.Elapsed.TotalSeconds -lt 60) { Start-Sleep -Seconds 1 } $r.Add("after_stop: state=" + (Get-Service ZKTecoSyncService).Status) Start-Sleep -Seconds 3 foreach ($p in @(Get-Process AttendanceHub.Sync.Host -ErrorAction SilentlyContinue)) { Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue Start-Sleep -Seconds 2 $r.Add("forced_exit_pid=$($p.Id)") } # 2) Backup current binaries $pub = "G:\WEB-SERVER\htdocs\AttendanceHub\ZKTecoSyncService-V2\publish" $bak = Join-Path $pub "bin_backup_pre_pumpfix_20261010" New-Item -ItemType Directory -Force -Path $bak | Out-Null foreach ($f in @('AttendanceHub.Sync.dll','AttendanceHub.Sync.Host.dll','AttendanceHub.Sync.Host.exe','AttendanceHub.Sync.Host.deps.json')) { Copy-Item (Join-Path $pub $f) (Join-Path $bak $f) -Force -ErrorAction SilentlyContinue $r.Add("backed_up $f") } # 3) Copy freshly published binaries (includes ingest filter + pump fix) $src = "G:\WEB-SERVER\htdocs\AttendanceHub\ZKTecoSyncService-V2\_build\publish-staging" foreach ($f in @('AttendanceHub.Sync.dll','AttendanceHub.Sync.Host.dll','AttendanceHub.Sync.Host.exe','AttendanceHub.Sync.Host.deps.json')) { $s = Join-Path $src $f if (Test-Path $s) { Copy-Item $s (Join-Path $pub $f) -Force $r.Add("copied $f len=" + (Get-Item (Join-Path $pub $f)).Length) } else { $r.Add("MISSING_PUBLISH $f") } } # 4) Start service $r.Add("---- start $(Get-Date -Format o)") & sc.exe start ZKTecoSyncService 2>&1 | Out-String | ForEach-Object { $r.Add($_.Trim()) } Start-Sleep -Seconds 15 $r.Add("final_state=" + (Get-Service ZKTecoSyncService).Status) $r.Add("final_pid=" + (Get-CimInstance Win32_Service -Filter "Name='ZKTecoSyncService'").ProcessId) $r.Add("deployEnd=$(Get-Date -Format o)") [System.IO.File]::WriteAllLines($outFile, $r) Write-Output "WROTE $outFile"