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
| Flow | Same-save participants | Separate/outside boundary | Consequence | Source |
|---|---|---|---|---|
| Request creation | Request, initial timeline/audit, request outbox | Attendance check occurs before; approved balance update occurs after | Request and balance can be separate commits | microservices/src/leave-service/Application/LeaveWorkflows.cs |
| Direct decision | Request, decision timeline/audit, decision outbox | Attendance recheck before; balance update after | Decision and usage are not one atomic commit | microservices/src/leave-service/Application/LeaveWorkflows.cs |
| Cancellation | Cancelled request, history, outbox | Approved-usage reversal after | Reversal is a second commit | microservices/src/leave-service/Application/LeaveWorkflows.cs |
| Workflow start | Initial request commit, then correlation/history commit | Workflow call between commits | Request can exist before correlation is stored | microservices/src/leave-service/Application/LeaveWorkflows.cs |
| Workflow callback | Decision/history/outbox, then balance update | Optional Workflow verification before; balance after | Callback decision and usage are separate commits | microservices/src/leave-service/Application/LeaveWorkflows.cs |
| Profile consumer | Projection and audit | Broker acknowledgement after save | Save failure is requeued | microservices/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
Related Articles
See Also
Keywords
- Transaction boundary
- Unit of work
- Application constraint
Revision Information
- Status: Draft
- Last reviewed: 2026-07-15
- Review cycle: Quarterly