Skip to main content

Leave Data Integrity and Transactions

Summary

Each EF SaveChanges call is the persistence commit boundary. Several business workflows deliberately use more than one save or call external services outside that boundary.

Audience

Backend developers, QA, architects, DevOps, and consistency reviewers.

Concept

FlowSame-save participantsSeparate/outside boundaryConsequenceSource
Request creationRequest, initial timeline/audit, request outboxAttendance check occurs before; approved balance update occurs afterRequest and balance can be separate commitsmicroservices/src/leave-service/Application/LeaveWorkflows.cs
Direct decisionRequest, decision timeline/audit, decision outboxAttendance recheck before; balance update afterDecision and usage are not one atomic commitmicroservices/src/leave-service/Application/LeaveWorkflows.cs
CancellationCancelled request, history, outboxApproved-usage reversal afterReversal is a second commitmicroservices/src/leave-service/Application/LeaveWorkflows.cs
Workflow startInitial request commit, then correlation/history commitWorkflow call between commitsRequest can exist before correlation is storedmicroservices/src/leave-service/Application/LeaveWorkflows.cs
Workflow callbackDecision/history/outbox, then balance updateOptional Workflow verification before; balance afterCallback decision and usage are separate commitsmicroservices/src/leave-service/Application/LeaveWorkflows.cs
Profile consumerProjection and auditBroker acknowledgement after saveSave failure is requeuedmicroservices/src/leave-service/Messaging/EmployeeProfileConsumer.cs

SaveChanges maps queued aggregate events into outbox rows before calling the EF base save, so aggregate changes, audit/timeline already tracked, and newly created outbox messages share that one commit. No explicit BeginTransaction or cross-save transaction was found.

Database-enforced integrity consists of 12 primary keys, four unique indexes, required/length/precision mappings, and no foreign keys. The model has no concurrency token, row-version mapping, check constraint, cascade/restrict relationship, or database overlap rule. State transitions, required rejection reason, positive units, date order, overlap checks, balance normalization, and profile stale/duplicate checks are application/domain rules. Logical identifiers are not referentially constrained.

Source References

  • microservices/src/leave-service/Infrastructure/LeaveDbContext.cs
  • microservices/src/leave-service/Infrastructure/Persistence.cs
  • microservices/src/leave-service/Application/LeaveWorkflows.cs
  • microservices/src/leave-service/Messaging/EmployeeProfileConsumer.cs

See Also

Keywords

  • Transaction boundary
  • Unit of work
  • Application constraint

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-15
  • Review cycle: Quarterly