Skip to content

Commit db7477e

Browse files
committed
Avoid stale compensation after transactional rollback
1 parent fd42939 commit db7477e

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

src/openstatspec/sql/wide.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
)
2121
from .dolt_conformance import DoltConformanceSource
2222
from .profiles import (
23-
preflight, preflight_identifier, statement_payload_bytes,
24-
validate_connection_url,
23+
MYSQL_WIRE_PROFILES, preflight, preflight_identifier,
24+
statement_payload_bytes, validate_connection_url,
2525
)
2626
from .normative import (
2727
binary64_type,
@@ -2040,6 +2040,11 @@ def count_rows(table: Table, condition: Any) -> int | None:
20402040
return {"inspection_error_type": type(inventory_error).__name__}
20412041

20422042

2043+
def _requires_compensating_import_cleanup(profile_name: str) -> bool:
2044+
"""Transactional profiles rely on rollback, never stale cleanup markers."""
2045+
return profile_name in MYSQL_WIRE_PROFILES
2046+
2047+
20432048
@contextmanager
20442049
def _import_cleanup_guard(
20452050
*, engine: Any, dataset_id: str, operation_id: str, data_table: Table,
@@ -2069,12 +2074,13 @@ def capture_boundary() -> dict[str, Any]:
20692074
yield state
20702075
except Exception as import_error:
20712076
try:
2072-
with engine.begin() as cleanup_connection:
2073-
_cleanup_import_state(
2074-
cleanup_connection, dataset_id=dataset_id,
2075-
operation_id=operation_id, data_table=data_table,
2076-
state=state, normative=normative, legacy=legacy,
2077-
)
2077+
if _requires_compensating_import_cleanup(profile_name):
2078+
with engine.begin() as cleanup_connection:
2079+
_cleanup_import_state(
2080+
cleanup_connection, dataset_id=dataset_id,
2081+
operation_id=operation_id, data_table=data_table,
2082+
state=state, normative=normative, legacy=legacy,
2083+
)
20782084
except Exception as cleanup_error:
20792085
inventory = _import_residual_inventory(
20802086
engine, dataset_id=dataset_id, operation_id=operation_id,

0 commit comments

Comments
 (0)