Run make RepCRec
to compile, output will be file called RepCRec
.
The program can then be run in multiple ways:
- usage:
./RepCRec <testCase.txt>
. Replacing "testCase" with the name of the test (i.e. test1). - usage:
./RepCRec
accepts standard input line by line. See input instructions below and test cases for examples. - usage:
./testCheck.sh
runs a shell script that runs all tests and places the output in./outputs
in the form of a.txt
file
Code compiles using gcc version 11.5.0
, written with C++17
- Serializable Snapshot Isolation (SSI)
- Replication
- Failure Recovery
- The database contains 20 distinct variables (
x1, ..., x20
). - Variables are distributed across 10 sites (
1 to 10
).
- Odd-indexed variables are stored on one site only, determined as
1 + (index number mod 10)
. - Even-indexed variables are replicated across all sites.
- Example:
x3
andx13
are stored on site 4.
- Each variable
xi
is initialized to10 * i
.
- This project uses a discrete event simulation structure. Each new line in the input means time advances by one, and there will be only one instruction per line.
- Each site maintains its own Serializable Snapshot Isolation information.
- If a site fails, all of its SSI information is erased.
- Writes:
- Writes can go to available sites.
- If a site fails after a write but before the transaction commits, the transaction must abort.
- Reads:
- A transaction
T
can read a variablexi
if it meets the following conditions:- For non-replicated variables: The site holding
xi
is up. - For replicated variables: The site containing
xi
was up from the last commit ofxi
untilT
began.
- For non-replicated variables: The site holding
- A transaction
- Detect and handle:
- First-committer-wins rule.
- Consecutive Read-Write (RW) edges forming a cycle in the serialization graph.
- Transactions do not restart automatically after aborting.
- Upon recovery:
- Non-replicated variables are available for reads and writes immediately.
- Replicated variables are available for writing but not reading until a committed write occurs after recovery.
-
Instructions are read from a file or standard input, one per line.
-
Examples:
begin(T1)
- Begin transactionT1
.R(T1, x4)
- TransactionT1
reads variablex4
.W(T1, x6, v)
- TransactionT1
writes valuev
tox6
on all available sites.dump()
- Print committed values of all variables on all sites.end(T1)
- End transactionT1
and print commit or abort status.fail(6)
- Site 6 fails.recover(7)
- Site 7 recovers.
-
Input is to be well defined
-
Reads:
- Example:
x4: 5
- Example:
-
Writes:
- Indicate affected sites.
-
Commit/Abort:
- Example:
T1 commits
,T1 aborts
.
- Example:
-
Dump:
- Committed values of all variables for each site, sorted by variable name.
- Example:
site 1 - x2: 6, x3: 2, ... x20: 3 site 10 - x2: 14, ... x8: 12, x9: 7, ... x20: 3
-
Wait:
- Example: 'T1 Waits'
-
Fail/Recover:
- Example: 'Site 7 Fails', 'Site 7 Recovers'.
begin(T1)
begin(T2)
begin(T3)
W(T1, x1, 5)
W(T3, x2, 32)
W(T2, x1, 17)
end(T1)
end(T3)
end(T2)
T1
commits.T3
commits.T2
aborts due to conflict withT1
.
- Transaction Manager (TM)
- Manages read and write requests.
- Routes requests to appropriate sites.
- Tracks sites' status (up/down).
- Ensures SSI and resolves conflicts.
- Data Manager (DM)
- Each site has an independent DM.
- Maintains commit times and failure/recovery history.
- Transactions waiting on a failed site will continue execution until commit time.
- Recovered sites require a committed write to enable reading of replicated variables.
- Testing is done with various failure and recovery scenarios.
- Verification of correctness of read and write operations under SSI is required.
- Assurance of proper handling of abort and commit conditions.
- Transactions must wait if no site containing the required data is available.
- A read rom a transaction that begins after the recovery of a site
s
or a replicated variablex
will not be allowed until a committed write tox
takes place ons
- Failure scenarios simulate real-world distributed database behavior.