Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
    npro  
 Modern all-safe Rust Network Protocol library supporting h1, h2, h3, ws, wt sans-IO and with socket IO + tls
git clone https://npro.rs/repo/npro
Author[]google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.c...> 2025-09-13 04:45 UTC
Committer[]Andy Green <andy@warmcat.com> 2025-09-13 04:47 UTC
Tree42619087519144306cbb5a2c675289f5b702401e   Raw Patch
 
builder: Fix race condition causing jobs to stall
builder: Fix race condition causing jobs to stall

The 'finished' status for a task step was being sent with the
second-to-last log message instead of the very last one.

This was because the check for sending the status was for when one item
remained in the log queue. Due to the LIFO processing of logs, this
was not the final log message to be sent.

This created a race condition where the server would receive the
'finished' status and issue the next task step while the builder was
still sending the final log for the previous step. This could put the
builder into a confused state and cause the job to stall.

The fix is to change the condition to send the 'finished' status only
with the actual last log message, which is when the log queue becomes
empty after processing the current chunk.
diff --git a/src/builder/b-comms.c b/src/builder/b-comms.c index 10c04f5..edce574 100644 --- a/src/builder/b-comms.c +++ b/src/builder/b-comms.c @@ -347,10 +347,7 @@ send_logs: ns->task->uuid, (unsigned long long)lws_now_usecs(), chunk->stdfd, (int)chunk->len); - if (ns->finished_when_logs_drained && ns->chunk_cache.count == 1) - /* - * Let the last guy report the finished state - */ + if (ns->finished_when_logs_drained && !ns->chunk_cache.count) n += lws_snprintf((char *)p + n, lws_ptr_diff_size_t(end, p) - (unsigned int)n, "\"finished\":%d,", ns->retcode);
Page fetched 0s ago, creation time: 2ms (vhost etag hits: 0%, cache hits: 0%)