This project provide a multi-node replication system for postgres db. It will replicate data from a leader into two other replications, and it can tolerate leader failure for transactions. To maintain serializability of transactions, optimistic validation approach has been used.
This project is written with JAVA using SpringBoot Framework. All dependencies are listed and managed with Maven.
Intellij IDEA is recommended to run the project. MAVEN and JDK can be easily set up with it.
Docker
Maven
JAVA > version 17
You can either use bellow steps or use the saved intellij configuration in the project (from EditConfiguration
run the APPLICATION
configuration).
running postgres nodes:
docker-compose up -d
Even if you stop services, databases will be saved into a volume. In case you wanted to remove them
run docker volume prune
after stopping services.
build the code:
mvn clean install
Start each of the three replication nodes:
mvn spring-boot:run -Dspring-boot.run.profiles=<leader/node1/node2>
Start the client:
mvn spring-boot:run -Dspring-boot.run.profiles=client
We provide command line interface in client
- Start new transaction with "normal" for readwrite transactions or "readonly" for readonly transaction
- Read value of x with "read x"
- Write value of x with "write x, y"
- Commit transaction with "commit" Follow the client log to see how to interact with it.