feat: integrate native diagnostics and coordinated CBB transactions
This commit is contained in:
1 parent
9e230e1a46
commit
da67de026f
91 files changed
+14370
-435
No files matched your search
@@ -17,6 +17,37 @@ _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)
|
||||
|
||||
_ICDB_MESSAGE = re.compile(r'(?<![A-Za-z0-9_])icdb(?![A-Za-z0-9_.\\/])', re.I)
|
||||
_FAILURE_MESSAGE = re.compile(
|
||||
r'\b(?:error|failed|failure|unable|cannot|could\s+not|lost|corrupt(?:ed|ion)?|'
|
||||
r'inconsistent|unsupported|refused|denied)\b|失败|错误|异常|无法|损坏|失联|拒绝|未完成', re.I)
|
||||
|
||||
|
||||
def _icdb_error_paragraphs(text, *, error_message=False):
|
||||
text = str(text or '').replace('\r', '')
|
||||
for record in _session_losses(text):
|
||||
yield record['native_message'].strip()
|
||||
for paragraph in text.splitlines():
|
||||
# A pathname or our own category label is not native error content.
|
||||
message = re.sub(r'\[[^\]\n]*[\\/][^\]\n]*\]', '', paragraph)
|
||||
if _ICDB_MESSAGE.search(message) and (error_message or _FAILURE_MESSAGE.search(message)):
|
||||
yield paragraph.strip()
|
||||
|
||||
|
||||
def icdb_error_content(text, *, error_message=False):
|
||||
"""Extract failure paragraphs mentioning iCDB; codes/healthy text do not qualify."""
|
||||
return '\n\n'.join(dict.fromkeys(_icdb_error_paragraphs(text, error_message=error_message)))
|
||||
|
||||
|
||||
def read_icdb_error(path, baseline):
|
||||
"""Retain only new native error content, with the same bounded freshness rules."""
|
||||
data, appended = _read_log_delta(path, baseline)
|
||||
if not appended and (not baseline or baseline.get('truncated') or 'icdb_errors' not in baseline):
|
||||
return ''
|
||||
previous = baseline.get('icdb_errors', [])
|
||||
return '\n\n'.join(message for message in _icdb_error_paragraphs(decode_log(data))
|
||||
if appended or ' '.join(message.split()) not in previous)
|
||||
|
||||
|
||||
def parse_session_loss(text):
|
||||
"""Keep the native target verbatim; never infer a local repair target."""
|
||||
@@ -68,9 +99,10 @@ def snapshot_log(path):
|
||||
losses = [_session_identity(record) for record in _session_losses(decode_log(tail))]
|
||||
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}
|
||||
except FileNotFoundError:
|
||||
return {'size': 0, 'tail_sha256': hashlib.sha256(b'').hexdigest()}
|
||||
return {'size': 0, 'tail_sha256': hashlib.sha256(b'').hexdigest(), 'icdb_errors': []}
|
||||
except OSError as error:
|
||||
return {'error': str(error)}
|
||||
|
||||
|
||||
Reference in new issue
Block a user