Operational reconciliation often starts by comparing the outcome recorded by every service that participated in a distributed transaction. Conflicting terminal outcomes prove a partial commit, while missing or unfinished outcomes leave the transaction in doubt.
Design a DistributedTransactionAuditor class:
DistributedTransactionAuditor() creates a stateless auditor.String[] audit(String[] records) returns one finding for every anomalous transaction.
Each record has the exact format:
state is "COMMITTED", "ABORTED", "PENDING", or "UNKNOWN". Transaction and service ids contain no colon.
Classify each transaction independently:
- If it contains at least one
COMMITTED and at least one ABORTED record, classify it as "PARTIAL_COMMIT". This takes precedence over unresolved states. - Otherwise, if it contains at least one
PENDING or UNKNOWN record, classify it as "IN_DOUBT". - Otherwise, every record agrees on commit or abort. The transaction is consistent and must be omitted.
Return findings as "transactionId:classification", sorted by transaction id in ascending lexicographic order.
Example 1:
Input:
Output:
Explanation: t1 has conflicting durable outcomes, t2 is consistently committed, and t3 has not reached a known terminal result.
Example 2:
Input:
Output:
Explanation: Transaction a is a consistent abort and is omitted. The unresolved transactions are sorted by id rather than input position.
Constraints
0 <= records.length <= 1000- Transaction and service ids contain
1 to 40 printable ASCII characters other than colon. - Every transaction-id and service-id pair appears at most once.
- Every state is
"COMMITTED", "ABORTED", "PENDING", or "UNKNOWN". - At most
100 calls are made to audit, and calls are independent.