Skip to content

Commit d592a98

Browse files
rayhpengclaude
andcommitted
docs: annotate DbRunEventStore.put() as low-frequency path
Add docstring clarifying that put() opens a per-call transaction with FOR UPDATE and should only be used for infrequent writes (currently just the initial human_message event). High-throughput callers should use put_batch() instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0af0ae7 commit d592a98

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • backend/packages/harness/deerflow/runtime/events/store

backend/packages/harness/deerflow/runtime/events/store/db.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ def _truncate_trace(self, category: str, content: str | dict, metadata: dict | N
5353
metadata = {**(metadata or {}), "content_truncated": True, "original_byte_length": len(encoded)}
5454
return content, metadata or {}
5555

56-
async def put(self, *, thread_id, run_id, event_type, category, content="", metadata=None, created_at=None):
56+
async def put(self, *, thread_id, run_id, event_type, category, content="", metadata=None, created_at=None): # noqa: D401
57+
"""Write a single event — low-frequency path only.
58+
59+
This opens a dedicated transaction with a FOR UPDATE lock to
60+
assign a monotonic *seq*. For high-throughput writes use
61+
:meth:`put_batch`, which acquires the lock once for the whole
62+
batch. Currently the only caller is ``worker.run_agent`` for
63+
the initial ``human_message`` event (once per run).
64+
"""
5765
content, metadata = self._truncate_trace(category, content, metadata)
5866
if isinstance(content, dict):
5967
db_content = json.dumps(content, default=str, ensure_ascii=False)

0 commit comments

Comments
 (0)