"""Two clients write the same table at the same time (what two controllers did with run 200273); both are killed.""" import json, os, signal, subprocess, sys, time sys.path.insert(0, "/Users/erhankeseli/projects/abap-llm/harness/scripts_probe") from lockprobe import * from killtest import VICTIM from killtabl import DDL def attempt(delay, n): name = "ZPROBE0K2_%03d" % n with McpClient() as m: m.call("sap_create_object", {"objectType": "TABL", "objectName": name, "packageName": "$TMP", "description": "two writers"}) args = {"objectType": "TABL", "objectName": name, "source": DDL.format(n=name.lower(), w=20 + n)} ps = [subprocess.Popen([sys.executable, "-c", VICTIM, json.dumps(args)], stdout=subprocess.PIPE, text=True) for _ in range(2)] for p in ps: assert p.stdout.readline().strip() == "SENT" time.sleep(delay) states = [] for p in ps: states.append("finished" if p.poll() is not None else "killed") try: os.kill(p.pid, signal.SIGKILL) except ProcessLookupError: pass p.wait() time.sleep(3) out = {"name": name, "delay": delay, "victims": states} with McpClient() as m: out["enqueue"] = read_locks(m) e, t = m.call("sap_push_source", {"objectType": "TABL", "objectName": name, "source": DDL.format(n=name.lower(), w=40 + n)}) out["follow_up"] = t[:300] out["leak"] = "[LOCK]" in out["follow_up"] or ("ZPROBE0K2" in out["enqueue"]) out["delete"] = {k.split("/")[-1]: v["deleted"] for k, v in delete_uris(["/sap/bc/adt/ddic/tables/" + name.lower()]).items()} return out if __name__ == "__main__": n = int(sys.argv[2]) for d in (float(x) for x in sys.argv[1].split(",")): o = attempt(d, n); n += 1 o["enqueue"] = o["enqueue"][:1200] print(json.dumps(o, indent=1)) if o["leak"]: print("LEAK at delay", d, "object", o["name"]); break