DEV Community

Saranya R
Saranya R

Posted on

Idempotency Situation

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

Situation:

  1. Imagine there are 2 accounts A which has a balance of 400 and B which has a balance of 150
    If A initiates a transfer of 100 to B,

  2. first transfer:
    A sends B 100, A=400-100-> 300, B=150+100-> 250.

  3. second transfer:
    A sends B 100 again, A=300-100 -> 200, B=250+100-> 350.

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)