feat: coordinate timeout chain and add failover load profile

HAProxy checks get fastinter 500ms and timeout check 2.5s (hung replica
detected within 6.5 s), http-reuse never with uvicorn keep-alive 60 s so
the LB closes idle replica connections, and app connections set
idle_in_transaction_session_timeout so a frozen replica releases its
idempotency key. The bench stand runs behind HAProxy with N replicas and
gains the failover profile (make bench_failover / bench_failover_quick):
constant-rate writes with a key and reads while each replica is stopped,
killed or paused, with per-second timeline, detection and recovery time
and write reconciliation. Driver commands idle-conns and hang-key check
the keep-alive and hung-transaction decisions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-10 23:21:12 +03:00
co-authored by Claude Opus 5.5
parent b76a666621
commit 459f84c75c
25 changed files with 2400 additions and 269 deletions
+10 -6
View File
@@ -4,7 +4,10 @@ import encoding from "k6/encoding";
import http from "k6/http";
import { check, fail } from "k6";
export const BASE_URL = __ENV.BASE_URL || "http://mtusi-bench-api:8080";
// через балансировщик стенда: имя сервиса haproxy — алиас в сети
// mtusi-bench, за ним Profile.replicas реплик (решение 6 design change
// graceful-failover)
export const BASE_URL = __ENV.BASE_URL || "http://haproxy:8080";
export const API = `${BASE_URL}/api/v1`;
// каталог метки (сырые итоги) и рабочий каталог (фикстура, курсоры)
export const OUT_DIR = __ENV.OUT_DIR || "/out";
@@ -31,11 +34,12 @@ export function authHeaders(token) {
// заголовки отправки сообщения: с лабы 3 обязателен Idempotency-Key. Новый
// ключ на каждую отправку (UUID v4 WebCrypto — допустимый алфавит
// контракта); стенд отправку не повторяет
export function messageHeaders(token) {
// контракта); стенд отправку не повторяет. Профиль отказа задаёт ключ сам:
// повтор неподтверждённой записи строит тот же ключ по номеру
export function messageHeaders(token, key = crypto.randomUUID()) {
return {
...authHeaders(token),
"Idempotency-Key": crypto.randomUUID(),
"Idempotency-Key": key,
};
}
@@ -96,12 +100,12 @@ export function createChat(ownerToken, title, memberIds) {
return res.json("id");
}
export function sendMessage(chatId, senderToken, text) {
export function sendMessage(chatId, senderToken, text, key = undefined) {
const res = http.post(
`${API}/chats/${chatId}/messages`,
JSON.stringify({ text }),
{
headers: messageHeaders(senderToken),
headers: messageHeaders(senderToken, key),
responseCallback: http.expectedStatuses(201),
},
);