codeant-ai-for-open-source[bot] commented on code in PR #45029:
URL: https://github.com/apache/superset/pull/45029#discussion_r4200503542


##########
superset/tasks/version_history_retention.py:
##########
@@ -351,8 +352,46 @@ def _chunked(items: list[int], size: int) -> 
Iterator[list[int]]:
 _METRIC_PREFIX: str = "superset.versioning.retention"
 
 
+def _live_bearing_tables(tables: ShadowTables) -> list[sa.Table]:
+    """Return every shadow table that can anchor a live transaction."""
+    live_bearing_tables: list[sa.Table] = [*tables.parent, *tables.child]
+    if tables.m2m is not None:
+        live_bearing_tables.append(tables.m2m)
+    return live_bearing_tables
+
+
+def _count_prunable(cutoff: datetime, tables: ShadowTables) -> int:
+    """Count the full eligible transaction backlog without writing rows."""
+    total: int = 0
+    after_id: int = 0
+    live_bearing_tables: list[sa.Table] = _live_bearing_tables(tables)
+    conn: sa.engine.Connection
+    with db.engine.connect() as conn:
+        while True:
+            window: _PruneWindow = _resolve_prune_window(
+                conn, cutoff, live_bearing_tables, after_id, _MAX_PRUNE_BATCH
+            )
+            total += len(window.prunable)
+            if window.candidate_count < _MAX_PRUNE_BATCH:
+                return total
+            after_id = window.max_candidate_id

Review Comment:
   ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and 
marked this thread resolved** as of `afb0591`.
   
   The connection context now opens inside each candidate-window iteration and 
closes before the next window is resolved, so the scan does not hold one read 
transaction across the full dry run.
   
   <sub>If that's not right, unresolve this thread and CodeAnt will leave it 
open.</sub>
   
   <!-- codeant-auto-resolve-reply -->



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to