Воспроизведите отправку сообщения при задержке публикатора

This commit is contained in:
2026-11-20 10:54:35 +03:00
parent 8f90c78b98
commit c27b681689
3 changed files with 14 additions and 3 deletions
+9 -2
View File
@@ -5,6 +5,7 @@ from concurrent.futures import ThreadPoolExecutor
from datetime import datetime, timezone
import hashlib
import json
import os
from pathlib import Path
import struct
import subprocess
@@ -243,6 +244,9 @@ class Experiment:
self.marker(api, marker, "release")
before = self.state(aid)
check(not before["jobs"][0]["confirmed"], "SQL confirmation already committed")
# Attaching a queued file must finish even while the publisher holds its row lock.
linked = self.client.message(self.actor, self.chat, "", attachments=[aid])
check(linked["json"]["attachment_ids"] == [aid], "message lost its attachment")
self.crash(owner)
self.marker(owner, marker, "release")
wait(lambda: self.state(aid)["jobs"][0]["confirmed"], "republished envelope")
@@ -265,7 +269,9 @@ class Experiment:
result = self.result(aid)
check(result["variant_count"] == 3 and result["jobs"][0]["attempt"] == 1, "publication crash duplicated the effect")
return {"broker_confirm_before_sql_commit": before, "confirmed_job_before_broker_restart": confirmed,
"broker_messages_before_restart":copies,"broker_messages_after_restart":restored,"after": result}
"message_while_publisher_held": {"id": linked["json"]["id"], "status": linked["status"],
"seconds": round(linked["elapsed"], 3)},
"broker_messages_before_restart": copies, "broker_messages_after_restart": restored, "after": result}
def worker_crash(self, phase, reference):
aid = self.queued()
@@ -406,7 +412,8 @@ class Experiment:
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--base-url", required=True)
parser.add_argument("--project", choices=["lab5"], required=True)
# Match the project selected for the Compose startup, including isolated review runs.
parser.add_argument("--project", choices=[os.environ.get("COMPOSE_PROJECT_NAME") or "lab5"], required=True)
parser.add_argument("--output", type=Path, required=True)
args = parser.parse_args()
exp = Experiment(args.base_url, args.project)