Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

3 watching

Forks

Repository files navigation

TxnSails

The code base of "TxnSails: Achieving Serializable Transaction Scheduling with Self-Adaptive Isolation Level Selection" and its distributed extension.

Configure single, distributed and mock execution in one TOML file, including all datasource settings. See the deployment guide for startup and adding nodes, and Distributed transactions for supported SQL, isolation and recovery. Mock mode runs real distributed branches on a shared PostgreSQL datasource. Node IDs may be sparse and the topology has no fixed node-count cap.

For TxnSailsD, CO and centralized certification on identical distributed data, see benchmark configuration. The fixed read/write profile uses Java and keeps every YCSB transaction at exactly 10 operations (5 reads and 5 writes by default):

./runBenchmark.sh benchmark/config/smoke
./generateBenchmarkConfig.sh benchmark/config/generator
./runBenchmark.sh benchmark/config/generated/eight-owners

The historical SCC-based CO / Global / TxnSails-D comparisons used 64 clients, a 10-second warmup and 30-second evaluation. See the PDF SQL audit, reproducible configurations and CSV/figure report. SmallBank and TPC-Ckv keep all PDF transactions active and vary only table placement; YCSB sweeps read/write ratio and Zipf skew with frozen templates.

Brief introduction

TxnSails works in the middle tier between database and application. It meets three requirements:

  1. It requires minimal modifications to client applications and database kernels, ensuring low implementation overhead.
  2. It must be efficient to handle dangerous structures under various lower isolation levels while ensuring SER.
  3. It must adaptively select the optimal isolation level to maximize performance in response to dynamic workloads.

The architecture of TxnSails is illustrated in figure below.

Architecture

Code description

Code Navigation

Key modules and corresponding source code:

  1. Analyzer - src/.../worker/OfflineWorker, src/.../analysis/*
  2. Executor - src/.../worker/OnlineWorker, src/.../execution/validation/*
  3. Adapter - src/.../worker/{Adapter, Flusher}, src/.../execution/sample/*, isolation_adapter/* (Python)
    • isolation\_adapter/graph\_construct: graph construction
    • isolation\_adapter/graph\_training: graph embedding and classfication
    • isolation\_adapter/services: offline training service and online prediction service
    • adapter.py: connection
  4. Client - benchmark/src/main/java/org/dbiir/txnsails/benchmark/; independent Java module with connections, template registration, transaction execution and measurement

Note: ... represents the filepath main/java/org/dbiir/txnsails.

Implementation

Analyzer: We first implemented a StaticDependencyGraph class that takes the transaction templates as input and builds a static dependency graph. Then, the graph is fed into the ChordAbsentCycleFinder class to detect cycles with characteristics defined in theorem 2.1. At last, it identifies the transaction templates involving static vulnerable dependencies and stores the results in MetaWorker instance.

Executor: It invokes SQLRewrite() function to rewrite queries, selecting the version of the record if its template is involved in static vulnerable dependencies. It then sends the rewritten query to the database and records the vid column. Additionally, we implement a crucial data structure, ValidationMetaTable, which is initialized before any transactions are received to perform middle-tier validation in single- or cross-isolation scenarios. It is organized as a hash table, with each bucket representing a list of ValidationMeta, including validation lock, latest version, and lease information. A dedicated thread is responsible for garbage collection of expired meta entries by comparing the lease and real-time system clock. Furthermore, we implement a WAIT-DIE strategy withinValidationMetaTable to prevent deadlocks.

Adapter: We first implemented a TransactionCollector class that collects the read and write sets for transactions adhering to Monte Carlo sampling. Then, we design a Flusher thread to flush the runtime dependency graph. Finally, Adapter is implemented with the help of the torch_geometric library. It inputs the runtime dependency group and outputs the optimal isolation level. To ensure cross-platform compatibility and efficiency, the Python and Java components communicate via sockets.

Client Libs

Interface description

We provide four apis for clients:

  • register() -> (status, serverSideIdx):
  • analyse() -> (status):
  • execute() -> (status, results/errorMsg):
  • commit()/rollback() -> (status):

Application developer should rebuild a portion of their code to utilize TxnSails' capabilities and TxnSails can automatically guarantee the serializable. Note that we do not modify the application workload to achieve serializable, for example, we do not either promote reads to writes or introduce outside lock manager. We would continue to improve above apis and TxnSails to support serializable transactions for more heterogeneous database systems, thereby further reducing application development costs.

How to use

  1. Modify application code according to above interfaces.
  2. Register the transaction templates into TxnSails.

Online workflow:

  1. Execute transactions by invoking execute() and commit()/rollback().

Offline workflow:

  1. generate random workload configurations
  2. run each workload under different isolation
    • sample the runtime dependency graph
  3. label the runtime dependency graph with the optimal isolation level according to the performance.

The isolation level selection and transition is transparent to clients and applications.

Evaluation

Environment and Configuration

We conducted our experiments on two in-cluster servers, each equipped with an Intel(R) Xeon(R) Platinum 8361HC CPU @ 2.60GHz processor, which includes 24 physical cores, 64 GB of DRAM, and a 500 GB SSD. The operating system was CentOS Linux release 7.9.

We utilize BenchBase as our benchmark simulator, deploying it on a single server. We modify it to interface with TxnSails. By default, the experiments are conducted using 128 client terminals. The sql statement is listed in BENCHMARK_SQL_Statement.pdf.

We deployed PostgreSQL 15.2 as the database engine. For our database configuration, we allocated a buffer pool size of 24GB, limited the maximum number of connections to 2000, and established a lock wait timeout of 100 ms. To eliminate network-related variables from affecting the results, both TxnSails and PostgreSQL were deployed on another server.

How to Build

The server and benchmark require JDK 21 and Maven 3.9+. The benchmark runs in Java and loads data through JDBC. Adapter dependencies are optional.

mvn -Dfmt.skip=true -DskipTests package
mvn -f benchmark/pom.xml package

How to Run

The Java benchmark reads benchmark.toml from one configuration directory, then loads the selected client TOML/XML files. All runtime parameters, including strategy, concurrency, timing, loading and process startup, come from these files. The command line accepts only an optional directory; no parameter overrides.

./runBenchmark.sh benchmark/config/smoke
./runBenchmark.sh benchmark/config/experiments/fixed-rw-ser
./runBenchmark.sh benchmark/config/experiments/fixed-rw-si

Set execution.local_postgres = true to create fresh disposable databases; this requires initdb and pg_ctl. Set it to false to use configured PostgreSQL datasources. Change execution.action to list, prepare or load for those steps. See benchmark usage and configuration reference. The former client submodule has been removed; the benchmark has no dependency on its checkout or adaptor.

The standalone server and three deployment modes are described in the deployment guide. Distributed dependency terminology and the conservative analyser are described in distributed static analysis.

Current distributed certification: TxnSailsD, using rule 1 OR rule 2; see definition. Existing reference64 results measure the historical SCC variant, not this version.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages