Skip to content

[featuer] 백엔드 스케쥴러 ShedLock 도입하여 중복 스케쥴링 방지#1186

Merged
lepitaaar merged 4 commits intodevelop/befrom
feature/#1185-add-shedlock-MOA-637
Feb 13, 2026
Merged

[featuer] 백엔드 스케쥴러 ShedLock 도입하여 중복 스케쥴링 방지#1186
lepitaaar merged 4 commits intodevelop/befrom
feature/#1185-add-shedlock-MOA-637

Conversation

@lepitaaar
Copy link
Contributor

@lepitaaar lepitaaar commented Feb 12, 2026

#️⃣연관된 이슈

#1185

📝작업 내용

ShedLock을 추가해 k8s 환경의 레플리카에 동시에 스케쥴링이 되지않게 방지하였습니다
또한 기존 모집상태를 추적하던 스케쥴러의 1시간이 길다고 판단되어 10분으로 줄였습니다

중점적으로 리뷰받고 싶은 부분(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

논의하고 싶은 부분(선택)

논의하고 싶은 부분이 있다면 작성해주세요.

🫡 참고사항

Summary by CodeRabbit

  • 개선사항
    • 모집 상태 확인 작업의 실행 주기가 10분으로 단축되어 더 빠른 상태 업데이트를 제공합니다(기존: 1시간).
    • 예약 작업에 분산 잠금 지원이 추가되어 동시에 실행되는 중복 작업을 방지하고 안정성이 향상됩니다.
    • 시스템 전반의 안정성과 일관성이 강화되었습니다.

@lepitaaar lepitaaar self-assigned this Feb 12, 2026
@lepitaaar lepitaaar added ✨ Feature 기능 개발 💾 BE Backend labels Feb 12, 2026
@vercel
Copy link

vercel bot commented Feb 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
moadong Ready Ready Preview, Comment Feb 12, 2026 2:08am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Invalid regex pattern for base branch. Received: "**" at "reviews.auto_review.base_branches[0]"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

ShedLock 의존성을 추가하고 MongoDB 기반 LockProvider 및 @EnableSchedulerLock 설정을 도입했으며, RecruitmentStateChecker 스케줄러에 @SchedulerLock을 적용하고 실행 주기를 1시간에서 10분으로 단축했습니다.

Changes

Cohort / File(s) Summary
빌드 의존성
backend/build.gradle
net.javacrumbs.shedlock:shedlock-spring:7.6.0...:shedlock-provider-mongo:7.6.0 의존성 추가.
Mongo 설정 / ShedLock 활성화
backend/src/main/java/moadong/global/config/MongoConfig.java
클래스에 @EnableSchedulerLock(defaultLockAtMostFor = "2m", defaultLockAtLeastFor = "30s") 추가 및 public LockProvider lockProvider(MongoClient) 빈 추가하여 new MongoLockProvider(mongoClient.getDatabase("shedLock")) 반환.
스케줄러 잠금 적용
backend/src/main/java/moadong/club/service/RecruitmentStateChecker.java
@SchedulerLock(name = "RecruitmentStateChecker", lockAtMostFor = "1m", lockAtLeastFor = "1s") 추가 및 fixedRate를 1시간(60601000)에서 10분(10601000)으로 변경.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Scheduler as RecruitmentStateChecker
participant LockProvider as MongoLockProvider
participant Mongo as MongoDB
Scheduler->>LockProvider: lock request (name="RecruitmentStateChecker")
LockProvider->>Mongo: create/verify lock document
Mongo-->>LockProvider: lock acquired
LockProvider-->>Scheduler: grant lock
Scheduler->>Scheduler: performTask()
Scheduler->>LockProvider: release/extend lock (as needed)
LockProvider->>Mongo: update/release lock document

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Zepelown
  • PororoAndFriends
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목에 오타 '[featuer]'가 있으나, 전체적으로 ShedLock 도입을 통한 중복 스케줄링 방지라는 변경사항의 핵심을 명확히 전달한다.
Linked Issues check ✅ Passed 코드 변경사항이 MOA-637의 목표인 'ShedLock 도입을 통한 중복 스케줄링 방지'를 충족한다. ShedLock 의존성 추가, 설정 구현, 스케줄러에 분산 잠금 적용이 모두 포함되어 있다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 ShedLock 도입과 스케줄 주기 변경이라는 정의된 범위 내에 있으며, 연관된 목표를 벗어나는 수정사항은 없다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/#1185-add-shedlock-MOA-637

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
backend/src/main/java/moadong/club/service/RecruitmentStateChecker.java (1)

29-41: performTask() 로직 자체는 문제없습니다.

ShedLock 락 설정만 조정되면 전체 흐름에 이슈는 없어 보입니다. 다만, 클럽 수가 증가할 경우 findAll() + 개별 save()의 성능이 병목이 될 수 있으므로 중장기적으로 saveAll() 배치 저장이나 변경된 클럽만 필터링하는 방식을 고려해 보시는 것을 권장합니다.

,


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Test Results

72 tests   72 ✅  16s ⏱️
14 suites   0 💤
14 files     0 ❌

Results for commit b152c91.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@backend/src/main/java/moadong/club/service/RecruitmentStateChecker.java`:
- Around line 27-28: The ShedLock timings on RecruitmentStateChecker (the
`@Scheduled` method performTask()) are too short — remove the method-level
lockAtMostFor/lockAtLeastFor attributes on the `@SchedulerLock` annotation so the
MongoConfig defaults (defaultLockAtMostFor = "2m" and defaultLockAtLeastFor =
"30s") apply, or if you prefer to keep overrides, increase lockAtMostFor to a
value comfortably above expected run time (e.g., >= 2m) and set lockAtLeastFor
to a higher value (tens of seconds) to match the 10-minute schedule; update the
`@SchedulerLock` on performTask() accordingly.
🧹 Nitpick comments (2)
backend/src/main/java/moadong/global/config/MongoConfig.java (2)

21-24: 하드코딩된 데이터베이스 이름 "shedLock" 대신 애플리케이션 설정을 활용하는 것을 권장합니다.

현재 MongoClient에서 직접 "shedLock" 데이터베이스를 가져오고 있어, 애플리케이션의 기본 MongoDB 데이터베이스와 별도의 DB가 생성됩니다. 이미 빈으로 등록된 MongoDatabaseFactory를 활용하면 애플리케이션과 동일한 데이터베이스 내에 ShedLock 컬렉션이 생성되어 관리가 더 용이합니다.

♻️ MongoDatabaseFactory 활용 제안
     `@Bean`
-    public LockProvider lockProvider(MongoClient mongoClient) {
-        return new MongoLockProvider(mongoClient.getDatabase("shedLock"));
+    public LockProvider lockProvider(MongoDatabaseFactory mongoDatabaseFactory) {
+        return new MongoLockProvider(mongoDatabaseFactory.getMongoDatabase());
     }

별도 DB를 의도적으로 사용하는 것이라면, 최소한 데이터베이스 이름을 application.yml에서 설정 가능하도록 외부화하는 것을 고려해 주세요.


13-13: @EnableSchedulerLock 기본값은 적절합니다.

defaultLockAtMostFor = "2m", defaultLockAtLeastFor = "30s" 설정은 10분 주기 스케줄러에 합리적인 기본값입니다. 다만, 이 어노테이션은 스케줄링 설정에 가까우므로 MongoConfig보다는 별도의 스케줄링 설정 클래스에 두는 것이 관심사 분리 측면에서 더 적절할 수 있습니다.

Copy link
Member

@seongwon030 seongwon030 left a comment

Choose a reason for hiding this comment

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

빠른 머지를 위한 승인

@Zepelown
Copy link
Member

락이 디비에 있는건가요?

@lepitaaar
Copy link
Contributor Author

락이 디비에 있는건가요?

맞습니다~

@lepitaaar lepitaaar merged commit 36c59f6 into develop/be Feb 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💾 BE Backend ✨ Feature 기능 개발

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants