Dual-Consistency problem of SEC in Saga.

Introduction

In the microservice architecture, It is highly concerned about the data consistency. As a result of that, you had to move in to the SAGA design pattern, and it ensures eventual consistency.

But the SEC also uses a database internally for storing the event data for retry purpose in StackSaga. SEC is also another program that supports for invoking your executions as a middleware framework. That means that all the execution data is saved in the database as events by the StackSaga framework before the real execution behind the scenes.

Because, in case your atomic transaction is failed for some reason, the atomic transaction should be rerun asynchronously. To retry the transaction, the old state of the transaction that the transaction was stopped should be persisted in the event-store.

According to the above definition, when an atomic transaction of the long-running transaction is executed by the SEC, the SEC creates an additional atomic transaction in its event store. However, since the SEC accesses the event store separately and has no control over the execution of the original atomic transaction, both transactions are executed independently. If the SEC fails to save its data in the database after successfully executing the original atomic transaction of the long-running transaction, it can break the Atomicity rule. This inconsistency arises due to the primary transaction is committed, but the SEC’s state remains incomplete, leading to potential data integrity issues.

In brief, The responsibility of protecting both data-consistencies of internal event-store and your transaction’s data-consistency is known as the Dual consistency problem of SEC.

read this for having a better understanding of how the SEC works.

How StackSaga overcomes the Dual-Consistency Problem

Then the framework is failed to provide the data consistency by themselves of their side. But the real fact, the first reason is for choosing a framework is to overcome the data consistency. But If the framework is not capable of handling the data consistency by itself, there is no point in using a framework.

In brief, The responsibility of protecting both data-consistency of internal event-store and your transaction’s data-consistency is known as the Dual consistency problem of SEC.