DEV Community

JAYA SRI J
JAYA SRI J

Posted on

idempotency situation

Idempotency is executing the same operation multiple times that will result in the same final state

Situation:

Imagine there are 2 accounts A which has a balance of 300 and B which has a balance of 100
If A initiates a transfer of 50 to B,

first transfer:
A sends B 100, A=300-50--> 250, B=100+50--> 200.

second transfer:
A sends B 100 again, A=200-50 --> 150, B=200+50--> 250.

From the situation, we can see that:

The system processes each request independently.
There is no mechanism to detect duplicates.
The same transaction is applied multiple times.

Result:

Incorrect account balances
Loss of data integrity
inconsistency

Top comments (0)