Skip to content

Commit e06d1b5

Browse files
committed
fix(daemon,win): give conflict-log share collisions a contention budget
The private-file prepare treated slow CONTENTION like permanent OBSTRUCTION: one 250 ms deadline for both. With many concurrent appenders on a loaded, sanitized runner the last writer can legitimately wait longer than that behind its peers' brief exclusive windows, and the concurrent-append guard correctly failed a dropped conflict event (dry run: one appender of the pack lost). Transient share/lock violations now retry against a 2000 ms contention budget while every other error class keeps the 250 ms fast-fail — a rejected client is still waiting behind this on the hello path. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent dc5649d commit e06d1b5

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎src/daemon/service.c‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,12 +856,26 @@ static bool windows_private_file_prepare(const char *directory, const char *base
856856
* to the ~16 ms timer granularity, and a permanently obstructed path
857857
* (e.g. a directory squatting on it) must fail fast — a rejected client
858858
* is waiting behind this on the hello path with its own timeout. */
859-
ULONGLONG deadline = GetTickCount64() + 250;
859+
ULONGLONG obstruction_deadline = GetTickCount64() + 250;
860+
/* Genuine share collisions get a wider budget than obstruction: with
861+
* many concurrent appenders on a loaded, sanitized CI runner the
862+
* last-in-line writer can legitimately spend more than 250 ms behind
863+
* its peers' brief exclusive windows, and the no-drop contract for
864+
* conflict events outranks latency there — while a permanently
865+
* obstructed path (a directory squatting on the name) still fails
866+
* inside 250 ms, because a rejected client is waiting behind this on
867+
* the hello path with its own timeout. */
868+
ULONGLONG contention_deadline = GetTickCount64() + 2000;
860869
for (;;) {
870+
SetLastError(ERROR_SUCCESS);
861871
FILE *file = cbm_daemon_ipc_private_log_open(directory, base, SIZE_MAX);
862872
if (file) {
863873
return fclose(file) == 0;
864874
}
875+
DWORD open_error = GetLastError();
876+
bool transient_collision =
877+
open_error == ERROR_SHARING_VIOLATION || open_error == ERROR_LOCK_VIOLATION;
878+
ULONGLONG deadline = transient_collision ? contention_deadline : obstruction_deadline;
865879
if (GetTickCount64() >= deadline) {
866880
return false;
867881
}

0 commit comments

Comments
 (0)