Skip to content

[Question] Why doesn’t Catalog decrement stock on validation, could this cause "overselling"? #888

Open

Description

@FlorentBunjaku1

I was checking the flow of order completion and noticed that when an OrderStatusChangedToAwaitingValidationIntegrationEvent is consumed by the Catalog service, it performs a check (without locking the DB) to see if there is stock for the items in the order. If stock is available, an OrderStockConfirmedIntegrationEvent gets published and payment is processed. After that, an OrderStatusChangedToPaidIntegrationEvent is published and handled by the Catalog service, this is the point where the stock actually gets removed for the ordered items.

To me, it looks like this could cause issues when two OrderStatusChangedToAwaitingValidationIntegrationEvent events are processed for the same product at the same time, or when one is already close to finishing the payment process. This might result in "overselling".

A simple solution would be to remove the stock right when the Catalog handles OrderStatusChangedToAwaitingValidationIntegrationEvent, which would also lock the row in SQL.

I know this isn’t a big deal since it’s just a reference app, but I was curious to know why it was designed this way, instead of “reserving” the stock during validation and then re-adding it if payment fails.

Activity

  1. carlsixsmith-moj commented on Dec 12, 2025

    @carlsixsmith-moj

    this is a duplicate of issue #732

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions