Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public class FlightScheduler {
* Cron: 초 분 시 일 월 요일
* 0 0 3 * * MON = 매주 월요일 3시
*/
@Scheduled(cron = "0 0 3 * * MON")
@Transactional
// @Scheduled(cron = "0 0 3 * * MON")
// @Transactional
Comment on lines +110 to +111
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

트랜잭션 경계 제거로 인한 데이터 무결성 위험

@Scheduled 어노테이션만 주석 처리하고 @Transactional은 유지해야 합니다. 현재 updateFlights() 메서드는 117번 라인에서 deleteAll()을 수행한 후 156번 라인에서 saveAll()을 수행합니다. 트랜잭션 없이 실행되면 saveAll() 중 오류 발생 시 데이터베이스가 비어있는 상태로 남게 되어 데이터 손실이 발생할 수 있습니다.

스케줄러를 비활성화하더라도 메서드가 수동으로 호출될 수 있으므로 트랜잭션 보호는 유지되어야 합니다.

🔎 제안하는 수정 방안
     // @Scheduled(cron = "0 0 3 * * MON")
-    // @Transactional
+    @Transactional
     public void updateFlights() {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// @Scheduled(cron = "0 0 3 * * MON")
// @Transactional
// @Scheduled(cron = "0 0 3 * * MON")
@Transactional
🤖 Prompt for AI Agents
In
@src/main/java/com/example/triptalk/domain/tripPlan/scheduler/FlightScheduler.java
around lines 110-111, The updateFlights() method in FlightScheduler currently
has @Scheduled commented out but @Transactional removed, which risks data loss
because deleteAll() runs before saveAll(); re-enable transactional boundary by
adding back the @Transactional annotation on the FlightScheduler.updateFlights()
method (or class) so that deleteAll() and saveAll() execute within a single
transaction, ensuring rollback on errors; keep @Scheduled commented if you want
the scheduler disabled but retain @Transactional to protect manual or
programmatic invocations.

public void updateFlights() {
log.info("=== 항공권 데이터 업데이트 시작 ===");

Expand Down Expand Up @@ -165,8 +165,8 @@ public void updateFlights() {
* 애플리케이션 시작 시 초기 데이터 로드
* (최초 실행 또는 DB가 비어있을 때)
*/
@Scheduled(initialDelay = 10000, fixedDelay = Long.MAX_VALUE) // 시작 10초 후 1회만 실행
@Transactional
// @Scheduled(initialDelay = 10000, fixedDelay = Long.MAX_VALUE) // 시작 10초 후 1회만 실행
// @Transactional
public void initialLoadFlights() {
long count = flightRepository.count();

Expand Down
Loading