Debugging Transactions and Tracking their Provenance with Reenactment

Xing Niu, Bahareh Sadat Arab, Seokki Lee, Su Feng, Xun Zou, Dieter Gawlick, Vasudha Krishnaswamy, Zhen Hua Liu, Boris Glavic

Abstract

Debugging database transactions is a complex task due to transient states, concurrency anomalies, and the risks associated with re-executing code on production systems. This paper presents a non-invasive debugging technique called reenactment. By leveraging existing temporal and audit logging features in modern database management systems (DBMS), reenactment translates transaction histories into declarative SQL queries. This allows developers to replay executions, inspect intermediate states, and track data provenance to diagnose bugs like write-skew anomalies without altering live data.

Introduction

Database developers often face significant hurdles when diagnosing transaction failures. Standard SQL debuggers frequently treat queries as "black boxes," obscuring internal dataflow. Furthermore, transactions often run under isolation levels lower than "Serializable," such as Snapshot Isolation, which can lead to subtle concurrency bugs that are difficult to reproduce. Traditional debugging methods—like re-running a transaction—are often impossible in production environments because they would modify live data.

To address these challenges, we propose a "post-mortem" debugging framework that requires no changes to the underlying DBMS or application code. The system provides a way to inspect the exact state of the database as seen by a past transaction, enabling precise diagnosis of logic errors and concurrency anomalies.

Methodology: The Reenactment Technique

The core of our approach is reenactment, a technique that simulates the effects of a transaction using a single, complex SQL query.

Declarative Replay

Instead of physical re-execution, the system transforms the imperative logic of a transaction into a declarative query. For instance, an UPDATE statement is modeled using a CASE expression that determines whether to return the original row or a modified version based on the transaction's parameters. This transformation allows the entire transaction history to be treated as a standard query.

Integration with GProM

The system is implemented within the GProM (Generic Provenance Middleware) framework. It utilizes two key features of modern DBMS:

  1. Audit Logs: To retrieve the original SQL statements and bind parameters.
  2. Time Travel (Temporal Tables): To access the database state at the exact moment the transaction began.

By combining these, GProM generates a "reenactment query" that produces the same results as the original transaction but runs as a read-only operation on historical data.

Case Study: Debugging Concurrency Anomalies

A primary use case for reenactment is diagnosing concurrency bugs like write-skew. Consider a scenario where two transactions attempt to withdraw money from different accounts belonging to the same customer, provided the total balance remains positive. Under Snapshot Isolation, both might succeed individually but leave the total balance negative.

Figure 1: A running example of two transactions (T1 and T2) resulting in a write-skew anomaly, illustrating the database state before and after execution.

As shown in Figure 1, reenactment allows a developer to step through the execution timeline. By tracking the provenance of the resulting tuples, the system can show exactly which input rows (e.g., the initial balances of the Checking and Savings accounts) contributed to an erroneous state, such as an unexpected overdraft record.

Evaluation and Results

The system was evaluated using synthetic workloads designed to trigger common anomalies and tested on a major commercial DBMS to measure overhead.

  • Performance: Reenactment queries can be generated and executed over tables with millions of rows in seconds, making the tool practical for real-world use.
  • Overhead: Enabling the necessary auditing and temporal features typically adds a 5% overhead for mixed workloads, rising to 20% for write-heavy scenarios. Since many enterprises already use these features for compliance, the marginal cost of debugging is often negligible.
  • What-If Analysis: Because reenactment is declarative, developers can modify the SQL or data within the debugger to test potential fixes without impacting the production database.

Conclusion and Future Work

Reenactment provides a powerful, non-invasive way to debug database transactions by treating them as queries. While currently focused on standard SQL, future work aims to support procedural extensions like PL/SQL and T-SQL. Additionally, the team is exploring advanced search tools to help developers locate specific problematic transactions within vast historical logs.

Summary updated

BibTeX
@article{niu2017debugging,
  author = {Xing Niu and Bahareh Sadat Arab and Seokki Lee and Su Feng and Xun Zou and Dieter Gawlick and Vasudha Krishnaswamy and Zhen Hua Liu and Boris Glavic},
  title = {{Debugging Transactions and Tracking their Provenance with Reenactment}},
  journal = {Proc. VLDB Endow.},
  year = {2017},
  doi = {10.14778/3137765.3137793},
}
Figure