Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

66%
+2 −0
Q&A How to reason about transaction isolation during development

One way to go is probably to use some kind of transaction scope to include everything (SELECT from order and INSERT into shipment) with a high enough transaction isolation (e.g. SERIALIZABLE for SQ...

posted 3y ago by Alexei‭

Answer
#1: Initial revision by user avatar Alexei‭ · 2021-03-06T07:02:09Z (about 3 years ago)
One way to go is probably to use some kind of transaction scope to include everything (SELECT from order and INSERT into shipment) with a high enough transaction isolation (e.g. SERIALIZABLE for SQL Server). However, this might prove very expensive if you need a high transaction throughput. 

**In practice, this is not an issue**:

- the likelihood of this happening is very low
- even if it happens, the shipment lifecycle is long enough to allow this to be checked later. E.g. I expect the system to have multiple states for a shipment. You have just created it here in your code, but there must be some validation later on.

While this might be strange for a developer, for most folks, **living in an inconsistent state for a while is perfectly natural** because most things take time to settle. Examples might include the period to get a new card, ID, or any type of license while the old one might be still in use. 

In your particular case having a shipment for a canceled order is not a big deal as long as this case is checked upon before actually dispatching the shipment. 

Of course, there are cases when this consistency must be enforced. If the likelihood of this happening is 1 in 100K and the result would be a plane crash, it cannot be allowed to happen.