fix(lastleg): read committed order command replays after lock waits

This commit is contained in:
2026-10-03 12:13:34 +08:00
parent 34cac9c42a
commit eadb431f33
6 changed files with 100 additions and 8 deletions
@@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.annotation.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.server.ResponseStatusException;
@@ -55,7 +56,9 @@ public class LastlegOrderCommandService {
@Resource private InventoryCommandService inventory;
@Resource private ObjectMapper objectMapper;
@Transactional
// Ownership is read before waiting for the order lock. Under MySQL repeatable
// read that snapshot can hide the preceding writer's idempotency record.
@Transactional(isolation = Isolation.READ_COMMITTED)
public LastlegOrderCommandDtos.HoldResponse hold(String requestedCustomerId, long orderId,
String idempotencyKey,
LastlegOrderCommandDtos.HoldRequest request,
@@ -122,7 +125,7 @@ public class LastlegOrderCommandService {
return response;
}
@Transactional
@Transactional(isolation = Isolation.READ_COMMITTED)
public LastlegOrderCommandDtos.ManualNodesResponse saveManualNodes(String requestedCustomerId, long orderId,
String idempotencyKey,
LastlegOrderCommandDtos.ManualNodesRequest request,