diff --git a/src/sync/access_reader.py b/src/sync/access_reader.py index 5e3b294..3189f32 100644 --- a/src/sync/access_reader.py +++ b/src/sync/access_reader.py @@ -111,8 +111,16 @@ class AccessReader: ) total += cur.rowcount break - except pyodbc.OperationalError: - if attempt < retries - 1: + except pyodbc.Error as e: + # ACE ODBC reports lock contention ("无法更新;当前被锁定。 + # (-1102)") as a generic ``pyodbc.Error`` (HY000), NOT as + # ``pyodbc.OperationalError`` — so the old handler silently + # missed it and gave up after the first collision. Retry only + # on lock messages; re-raise anything else so genuine errors + # surface immediately instead of being retried 3×. + msg = str(e) + is_lock = "被锁定" in msg or "-1102" in msg + if is_lock and attempt < retries - 1: time.sleep(0.2 * (attempt + 1)) else: raise