|
20 | 20 | ) |
21 | 21 | from .dolt_conformance import DoltConformanceSource |
22 | 22 | 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, |
25 | 25 | ) |
26 | 26 | from .normative import ( |
27 | 27 | binary64_type, |
@@ -2040,6 +2040,11 @@ def count_rows(table: Table, condition: Any) -> int | None: |
2040 | 2040 | return {"inspection_error_type": type(inventory_error).__name__} |
2041 | 2041 |
|
2042 | 2042 |
|
| 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 | + |
2043 | 2048 | @contextmanager |
2044 | 2049 | def _import_cleanup_guard( |
2045 | 2050 | *, engine: Any, dataset_id: str, operation_id: str, data_table: Table, |
@@ -2069,12 +2074,13 @@ def capture_boundary() -> dict[str, Any]: |
2069 | 2074 | yield state |
2070 | 2075 | except Exception as import_error: |
2071 | 2076 | 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 | + ) |
2078 | 2084 | except Exception as cleanup_error: |
2079 | 2085 | inventory = _import_residual_inventory( |
2080 | 2086 | engine, dataset_id=dataset_id, operation_id=operation_id, |
|
0 commit comments