fix: bind manual recovery entries and current native diagnostics
This commit is contained in:
1 parent
8374cabe5c
commit
601dd7b6b2
14 files changed
+694
-69
No files matched your search
@@ -8,7 +8,7 @@ import re
|
||||
ERROR_CODE = 'ICDB_REPAIR_REQUIRED'
|
||||
LOG_LIMIT = 128 * 1024
|
||||
RECOVERY_ACTION = (
|
||||
'停止批次并确认原服务器及其他客户端已正常关闭;保留完整一致副本后,'
|
||||
'停止受影响工程的写入并确认原服务器及其他客户端已正常关闭;保留完整一致副本后,'
|
||||
"使用同版本 iCDB Project Backup 的 Repair project 检查并修复正确目标。"
|
||||
'共享符号库问题需核对中心库,不能只修复单个 CBB 的 Work 工程。'
|
||||
'不要删除 sAddress.adr/锁文件;修复后重新打开、校验并确认权威 READY。'
|
||||
@@ -16,6 +16,9 @@ RECOVERY_ACTION = (
|
||||
_SESSION_LOSS = re.compile(
|
||||
r'\bthe\s+last\s+server\s+session\s+on\s+different\s+server\s+machine\s+'
|
||||
r'lost\s+the\s+connection\s+to\s+the\s+database\b', re.IGNORECASE)
|
||||
_INCONSISTENT = re.compile(
|
||||
r"Project database \[([^\]\r\n]+)\] is inconsistent\. It has been manually copied while the iCDB Server was running\.\s*"
|
||||
r"Please use iCDB Project Backup 'Repair project' functionality to fix this issue\.", re.I)
|
||||
|
||||
_ICDB_MESSAGE = re.compile(r'(?<![A-Za-z0-9_])icdb(?![A-Za-z0-9_.\\/])', re.I)
|
||||
_FAILURE_MESSAGE = re.compile(
|
||||
@@ -78,11 +81,25 @@ def parse_session_loss(text):
|
||||
return record
|
||||
|
||||
|
||||
def parse_recovery_request(text):
|
||||
record = parse_session_loss(text)
|
||||
if record is not None:
|
||||
return record
|
||||
match = _INCONSISTENT.search(str(text or ''))
|
||||
if match is not None:
|
||||
shared = 'symbollibs' in ntpath.normpath(match[1]).casefold().split('\\')
|
||||
return {'error_code': ERROR_CODE, 'kind': 'database_inconsistent',
|
||||
'native_message': match[0], 'database_path': match[1], 'scope': 'central_library' if shared else 'project',
|
||||
'machine': '', 'session': ''}
|
||||
return None
|
||||
|
||||
|
||||
def recovery_detail(record):
|
||||
target = ('中心库共享符号数据库' if record['scope'] == 'central_library' else
|
||||
'工程数据库' if record['scope'] == 'project' else '报错中指定的数据库')
|
||||
reason = '数据库副本不一致' if record.get('kind') == 'database_inconsistent' else '上次服务器会话失联'
|
||||
return (
|
||||
f"{ERROR_CODE}: {target}的上次服务器会话失联。\n"
|
||||
f"{ERROR_CODE}: {target}{reason};发现问题,未修复。\n"
|
||||
f"{record['native_message']}\n"
|
||||
f'{RECOVERY_ACTION}'
|
||||
)
|
||||
@@ -100,7 +117,8 @@ def snapshot_log(path):
|
||||
return {'size': size, 'tail_sha256': hashlib.sha256(tail).hexdigest(),
|
||||
'truncated': size > LOG_LIMIT,
|
||||
'icdb_errors': [' '.join(message.split()) for message in _icdb_error_paragraphs(decode_log(tail))],
|
||||
'session_losses': losses}
|
||||
'session_losses': losses,
|
||||
'inconsistent_databases': [match[1] for match in _INCONSISTENT.finditer(decode_log(tail))]}
|
||||
except FileNotFoundError:
|
||||
return {'size': 0, 'tail_sha256': hashlib.sha256(b'').hexdigest(), 'icdb_errors': []}
|
||||
except OSError as error:
|
||||
@@ -161,6 +179,12 @@ def read_log_failure(path, baseline):
|
||||
historical = baseline.get('session_losses', []) if baseline else []
|
||||
recovery = next((record for record in _session_losses(text)
|
||||
if appended or _session_identity(record) not in historical), None)
|
||||
if recovery is None:
|
||||
old = baseline.get('inconsistent_databases') if baseline else None
|
||||
match = next((match for match in _INCONSISTENT.finditer(text)
|
||||
if appended or old is not None and match[1] not in old), None)
|
||||
if match is not None:
|
||||
recovery = parse_recovery_request(match[0])
|
||||
return text, recovery
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user