Skip to content

Add transaction support to prevent data corruption in multi-step database operations #88

@Adityuh1

Description

@Adityuh1

Problem :
The backend/database/db_connection.py (lines 37-68) lacks transaction support, meaning multi-step database operations can leave the system in an inconsistent state if any intermediate step fails.

Scenario 1: File Creation with Metadata Loss

  1. File created in storage
  2. Permission record creation FAILS
    → Result: File exists but has no access control

Scenario 2: File Deletion with Audit Trail Loss

  1. File deleted from storage
  2. Audit log insert FAILS
    → Result: No record of deletion, compliance violations

Scenario 3: Permission Grant with Encryption Desync

  1. Permission updated in DB
  2. Encryption key update FAILS
    → Result: User can't access encrypted data with new permissions

Current Implementation Issues :
No rollback mechanism for failed operations
No atomic guarantees for multi-step processes
No isolation levels for concurrent operations
No constraint violations checking

Expected Behavior :
All multi-step database operations should be atomic , either all steps succeed or all are rolled back to the initial state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions