Skip to content

[Bug] StudyService.submit() missing @Transactional — data inconsistency risk #25

Description

@lechan775

Problem

StudyService.submit() performs 4-5 sequential database writes without transaction boundaries:

studyMapper.insertStudyRecord(...);       // ① 
studyMapper.insertWrongWord(...);         // ②
studyMapper.updateUserStats(...);         // ③
studyMapper.ensureUserBook(...);          // ④
studyMapper.updateUserBookProgress(...);  // ⑤

If step ③ fails (e.g. deadlock, connection timeout), steps ①② have already committed dirty data.

Proposed Solution

Add @Transactional to the submit() method and ensure the MyBatis mapper methods participate in the same transaction.

Affected

  • service/StudyService.java
  • Potentially mapper/StudyMapper.java (verify auto-commit settings)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions