Fix request_id mismatch causing 5s hang on every PUT commit

The COMMIT_PUT message was built with request_id N, then request_id
was incremented to N+1 immediately after sending. When the server
replied with request_id N, the client compared it against N+1,
silently discarded the reply, and waited for the 5-second timeout.
The timeout retry (replay_request) then resent with N+1, which
matched — so every PUT paid an unnecessary 5-second penalty.

Move the request_id++ before building the CommitPutMessage, matching
the pattern already used by toastyfs_async_delete.

https://claude.ai/code/session_01EG3WZSH3ZeTdAbb5T42r2w
This commit is contained in:
Claude
2026-02-21 23:36:18 +00:00
parent 15a2713116
commit 7da254fc45
+1 -1
View File
@@ -455,6 +455,7 @@ static int process_message(ToastyFS *tfs,
begin_transfers(tfs); begin_transfers(tfs);
if (all_chunk_transfers_completed(tfs)) { if (all_chunk_transfers_completed(tfs)) {
tfs->request_id++;
CommitPutMessage msg = { CommitPutMessage msg = {
.base = { .base = {
.version = MESSAGE_VERSION, .version = MESSAGE_VERSION,
@@ -477,7 +478,6 @@ static int process_message(ToastyFS *tfs,
msg.oper.chunks[i].size = tfs->chunk_sizes[i]; msg.oper.chunks[i].size = tfs->chunk_sizes[i];
} }
send_message_to_server(tfs, leader_idx(tfs), &msg.base); send_message_to_server(tfs, leader_idx(tfs), &msg.base);
tfs->request_id++;
tfs->step = STEP_COMMIT; tfs->step = STEP_COMMIT;
client_log(tfs, "SEND COMMIT_PUT", "key=%s chunks=%d req=%lu", client_log(tfs, "SEND COMMIT_PUT", "key=%s chunks=%d req=%lu",
tfs->key, tfs->num_chunks, tfs->request_id); tfs->key, tfs->num_chunks, tfs->request_id);