[FEATURE] 워터마크 재처리 스케줄러 추가#120
Conversation
|
Warning Review limit reached
Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough드래프트 파일에 TTF 텍스트 워터마크 생성과 이미지 처리 예외 타입이 추가됐다. 워터마크 실패 횟수와 상태 전이를 저장하며, 실패·정체 파일을 10분마다 조회해 선점 후 비동기로 재처리한다. Changes워터마크 처리 파이프라인
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/main/java/ditda/backend/global/config/WatermarkAsyncConfig.java (1)
14-21: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win워터마크 전용 executor에 큐 제한과 S3 타임아웃을 추가하세요.
DraftWatermarkService가 이 executor에서 S3 다운로드/업로드를 수행하므로, 단일 스레드 + 무제한 큐 상태에서는 S3 지연 시 작업이 계속 적재되고 이후 워터마크 처리도 막힙니다.WatermarkAsyncConfig에setQueueCapacity(...)로 상한을 두고, S3 클라이언트에도 connect/read/api timeout을 명시해 주세요.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/ditda/backend/global/config/WatermarkAsyncConfig.java` around lines 14 - 21, Update the watermark executor configuration in WatermarkAsyncConfig to set a finite queue capacity while preserving its single-thread behavior, and configure the S3 client used by DraftWatermarkService with explicit connect, read, and API timeouts. Reuse the project’s existing timeout and queue-capacity conventions where available.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/java/ditda/backend/domain/commission/draft/service/WatermarkRetryService.java`:
- Around line 47-55: WatermarkRetryService.java:47-55의 claimForRetry 결과를 활용해 실제
선점된 파일 ID만 reprocessFile로 큐잉하도록 변경하고, 필요하면 선점 ID 목록 반환 또는 선점 후 재조회 방식을 적용하세요.
CommissionDraftFileRepository.java:48-62의 claimForRetry WHERE 조건은 completed 제외가
아니라 원본 상태가 FAILED이거나 PROCESSING이면서 updatedAt이 stuckBefore보다 이전인 경우만 허용하도록 수정해 이미
선점된 파일의 재선점을 차단하세요.
- Around line 28-58: Update WatermarkRetryService.retryIncompleteFiles and its
repository flow so PROCESSING files that have reached MAX_WATERMARK_RETRY are
also selected and transitioned to FAILED, rather than being excluded
indefinitely. Add a separate bulk state-transition path for these exhausted
stuck records, while preserving the existing retry claim and reprocess flow for
eligible files below the retry limit.
---
Nitpick comments:
In `@src/main/java/ditda/backend/global/config/WatermarkAsyncConfig.java`:
- Around line 14-21: Update the watermark executor configuration in
WatermarkAsyncConfig to set a finite queue capacity while preserving its
single-thread behavior, and configure the S3 client used by
DraftWatermarkService with explicit connect, read, and API timeouts. Reuse the
project’s existing timeout and queue-capacity conventions where available.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: 56eebd21-d7cb-410c-b7b9-38c0f22f8abc
⛔ Files ignored due to path filters (1)
src/main/resources/images/watermark-logo.pngis excluded by!**/*.png
📒 Files selected for processing (17)
src/main/java/ditda/backend/domain/commission/draft/entity/CommissionDraftFile.javasrc/main/java/ditda/backend/domain/commission/draft/event/DraftFilesSubmittedEvent.javasrc/main/java/ditda/backend/domain/commission/draft/facade/DesignerDraftFacade.javasrc/main/java/ditda/backend/domain/commission/draft/listener/DraftWatermarkListener.javasrc/main/java/ditda/backend/domain/commission/draft/repository/CommissionDraftFileRepository.javasrc/main/java/ditda/backend/domain/commission/draft/scheduler/WatermarkRetryScheduler.javasrc/main/java/ditda/backend/domain/commission/draft/service/DraftWatermarkService.javasrc/main/java/ditda/backend/domain/commission/draft/service/DraftWatermarkTransitionService.javasrc/main/java/ditda/backend/domain/commission/draft/service/WatermarkRetryService.javasrc/main/java/ditda/backend/domain/commission/revision/facade/DesignerRevisionFacade.javasrc/main/java/ditda/backend/global/config/WatermarkAsyncConfig.javasrc/main/java/ditda/backend/global/image/WatermarkImageProcessor.javasrc/main/java/ditda/backend/global/image/dto/WatermarkedImage.javasrc/main/java/ditda/backend/global/image/exception/ImageErrorCode.javasrc/main/java/ditda/backend/global/s3/manager/S3FileManager.javasrc/test/java/ditda/backend/domain/commission/draft/service/DraftWatermarkServiceTest.javasrc/test/java/ditda/backend/global/image/WatermarkImageProcessorTest.java
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/java/ditda/backend/global/image/WatermarkImageProcessor.java (1)
103-103: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win인덱스 색상 모델(Indexed Color) 이미지의 투명도 깨짐을 방지하기 위한 ARGB 변환
reader.read()로 읽어온 원본 이미지가 GIF나 8비트 PNG 등 인덱스 색상 모델(TYPE_BYTE_INDEXED)이거나 커스텀 색상 공간(TYPE_CUSTOM)인 경우, 이후AlphaComposite으로 워터마크를 그릴 때 투명도가 제대로 적용되지 않거나 색상이 깨지는 현상이 발생할 수 있습니다.
원본 이미지의 포맷에 관계없이 워터마크가 일관된 품질로 렌더링되도록, 제한된 색상 모델을 가진 이미지는ARGB타입으로 변환 후 반환하는 것을 권장합니다.♻️ ARGB 변환 로직 추가
- return reader.read(0, param); + BufferedImage img = reader.read(0, param); + + // 인덱스 색상 모델이거나 커스텀 색상인 경우 투명도 처리를 위해 ARGB로 변환 + if (img.getType() == BufferedImage.TYPE_BYTE_INDEXED || + img.getType() == BufferedImage.TYPE_BYTE_BINARY || + img.getType() == BufferedImage.TYPE_CUSTOM) { + + BufferedImage argb = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics2D g = argb.createGraphics(); + g.drawImage(img, 0, 0, null); + g.dispose(); + return argb; + } + + return img;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/ditda/backend/global/image/WatermarkImageProcessor.java` at line 103, Update the image-loading flow around reader.read(0, param) to convert images with TYPE_BYTE_INDEXED or TYPE_CUSTOM color models into a TYPE_INT_ARGB BufferedImage before returning them. Preserve already compatible image types unchanged, and ensure the converted image retains the original dimensions and rendered transparency.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/main/java/ditda/backend/global/image/WatermarkImageProcessor.java`:
- Line 103: Update the image-loading flow around reader.read(0, param) to
convert images with TYPE_BYTE_INDEXED or TYPE_CUSTOM color models into a
TYPE_INT_ARGB BufferedImage before returning them. Preserve already compatible
image types unchanged, and ensure the converted image retains the original
dimensions and rendered transparency.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: 04d85a7d-b637-4ea9-ba73-fe669a755f53
⛔ Files ignored due to path filters (1)
src/main/resources/fonts/watermark-font.ttfis excluded by!**/*.ttf
📒 Files selected for processing (1)
src/main/java/ditda/backend/global/image/WatermarkImageProcessor.java
|
기존 이미지 워터마크에서 폰트 ( |
fervovita
left a comment
There was a problem hiding this comment.
수고하셨습니다!!
아래 코멘트 확인 부탁드려요😄
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/resources/db/migration/V260716013618__add_watermark_retry_count.sql`:
- Around line 11-12: Update the commission_draft_files migration to add
watermark_retry_count safely for existing rows: provide a temporary/default
value of 0 or add it nullable, backfill existing NULL values to 0, then enforce
the NOT NULL constraint. Ensure the completed column contains 0 for all
pre-existing records.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: 59ca113e-c6b5-4189-95d7-e400f8d81488
⛔ Files ignored due to path filters (1)
src/main/resources/fonts/LINESeedSans_Bd.ttfis excluded by!**/*.ttf
📒 Files selected for processing (10)
src/main/java/ditda/backend/domain/commission/draft/entity/CommissionDraftFile.javasrc/main/java/ditda/backend/domain/commission/draft/repository/CommissionDraftFileRepository.javasrc/main/java/ditda/backend/domain/commission/draft/service/DraftWatermarkService.javasrc/main/java/ditda/backend/domain/commission/draft/service/DraftWatermarkTransitionService.javasrc/main/java/ditda/backend/domain/commission/draft/service/WatermarkRetryService.javasrc/main/java/ditda/backend/global/image/WatermarkImageProcessor.javasrc/main/java/ditda/backend/global/image/exception/ImageErrorCode.javasrc/main/java/ditda/backend/global/image/exception/ImageProcessingException.javasrc/main/resources/db/migration/V260716013618__add_watermark_retry_count.sqlsrc/test/java/ditda/backend/global/image/WatermarkImageProcessorTest.java
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/java/ditda/backend/domain/commission/draft/service/WatermarkRetryService.java
- src/test/java/ditda/backend/global/image/WatermarkImageProcessorTest.java
- src/main/java/ditda/backend/global/image/WatermarkImageProcessor.java





🚀 Related issue
Closes #116
#️⃣ Summary
PROCESSING) 파일을 주기적으로 재처리하는 스케줄러를 추가했습니다.🔧 Changes
WatermarkRetryScheduler— 10분 주기로 미완료 워터마크 재처리CommissionDraftFile— 재시도 카운트(watermarkRetryCount) 및 워터마크 상태 전이 메서드 추가findWatermarkRetryTargetIds+claimForRetry— 재처리 대상을 원자적으로 선점(PROCESSING 전이 + 카운트 증가)해 중복 큐잉 방지BATCH_SIZE = 20) 적용📸 Test Evidence
💬 Reviewer Notes
claimForRetry벌크 UPDATE로 대상을PROCESSING으로 선점하며updatedAt을 갱신해 다음 틱의 재선정을 차단했습니다.fail()에 도달하지 못하고 멈춘(hang) 파일도 재시도 한도(MAX_WATERMARK_RETRY = 3)에 걸려 종료되도록 했습니다.Summary by CodeRabbit
새 기능
버그 수정