Завершить трек 2: burn-rate alerts, повторные эксперименты и отчёт

This commit is contained in:
2026-11-27 17:23:49 +03:00
parent 0355ba13d2
commit a5c650bcf5
50 changed files with 69318 additions and 300 deletions
+4 -2
View File
@@ -38,10 +38,11 @@ def prom(expr):
class DBLock:
"""Bounded SQL lock in this project's DB; health reads remain usable."""
def start(self):
def start(self,table='messages'):
check(table in ('messages','attachment_variants'),'unsupported fault table')
self.process=subprocess.Popen(['docker','compose','-p',PROJECT,'exec','-T','db',
'env','PGAPPNAME=lab6-fault-lock','psql','-U','messenger','-d','messenger','-c',
'BEGIN; LOCK TABLE messages IN ACCESS EXCLUSIVE MODE; SELECT pg_sleep(180); COMMIT;'],
f'BEGIN; LOCK TABLE {table} IN ACCESS EXCLUSIVE MODE; SELECT pg_sleep(180); COMMIT;'],
cwd=ROOT,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
time.sleep(.5)
check(self.process.poll() is None,'SQL fault process failed')
@@ -57,6 +58,7 @@ def snapshot():
result=[]
for row in json.loads(subprocess.check_output(['docker','inspect',*ids],text=True)):
result.append({'id':row['Id'],'service':row['Config']['Labels']['com.docker.compose.service'],
'image_id':row['Image'],'image_name':row['Config']['Image'],
'started_at':row['State']['StartedAt'],'status':row['State']['Status'],
'oom_killed':row['State']['OOMKilled'],
'memory_limit':row['HostConfig']['Memory'],'nano_cpus':row['HostConfig']['NanoCpus']})