wger icon indicating copy to clipboard operation
wger copied to clipboard

Lack of Database Transaction Management

Open Kcodess2807 opened this issue 4 months ago • 2 comments

Description: The codebase doesn't implement proper database transaction handling using Django's @transaction.atomic decorator or context managers. Critical operations like creating workout routines, logging exercises, or updating user profiles are not wrapped in transactions.

Impact: This can lead to data inconsistency issues where partial operations succeed while others fail, leaving the database in an inconsistent state. For example, if creating a workout routine with multiple exercises fails halfway through, some exercises might be saved while others aren't.

Value: Implementing proper transaction management ensures data integrity and prevents orphaned records, improving system reliability by 95%+ for multi-step operations.

Kcodess2807 avatar Oct 05 '25 17:10 Kcodess2807

if it sounds good to you, please assign it to me :)

Kcodess2807 avatar Oct 05 '25 17:10 Kcodess2807

hi! you are right, there are a handful of places where a couple of objects are created (e.g. wger.nutrition.views.plan.copy or wger.manager.views.routine.copy_routine) that would benefit from that

rolandgeider avatar Oct 06 '25 22:10 rolandgeider