Skip to content

Conversation

@Pinkippo
Copy link
Member

No description provided.

- ExecutorService 포화 방지를 위한 배치 처리 및 CallerRunsPolicy 적용
- 실패한 알림도 전송 완료로 표시하여 재시도 방지
@Pinkippo Pinkippo requested review from Copilot and wngns1101 October 30, 2025 06:16
@Pinkippo Pinkippo self-assigned this Oct 30, 2025
@Pinkippo Pinkippo merged commit 9785b6c into main Oct 30, 2025
5 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements resilience improvements for the push notification system to prevent thread pool exhaustion and handle notification failures more gracefully.

  • Adds a CallerRunsPolicy rejection handler to the async executor configuration
  • Marks failed notifications as sent to prevent infinite retry loops
  • Implements batch processing with delays for sending notifications to all users

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
AsyncConfig.java Adds a rejection execution handler to prevent task rejection when thread pool is saturated
PushNotificationService.java Updates failure handling to mark failed notifications as sent, preventing retry loops
NotificationTemplateService.java Introduces batch processing with inter-batch delays to avoid overwhelming the thread pool

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

);
sentCount++;
} else {
final int BATCH_SIZE = 20; // 배치 크기 설정 (스레드 풀 용량 35개 고려)
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

The comment mentions thread pool capacity of 35, but the AsyncConfig shows maxPoolSize=10 and queueCapacity=25 (total capacity of 35). However, this is misleading since the queue only holds pending tasks, not active threads. The actual concurrent execution capacity is 10 threads. Consider clarifying this as '스레드 풀 총 용량 35개 (최대 스레드 10개 + 큐 25개) 고려' to accurately reflect the distinction between thread capacity and queue capacity.

Suggested change
final int BATCH_SIZE = 20; // 배치 크기 설정 (스레드 풀 용량 35개 고려)
final int BATCH_SIZE = 20; // 배치 크기 설정 (스레드 풀 용량 35개 [최대 스레드 10개 + 큐 25개] 고려)

Copilot uses AI. Check for mistakes.
log.debug("배치 처리 중: {}/{} (배치 크기: {})",
endIndex, activeUsers.size(), batch.size());

/// 푸시 알림 전송
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

[nitpick] This comment uses triple slashes (///) which is inconsistent with the double slash (//) comment style used elsewhere in the same method (lines 189). The codebase consistently uses triple slashes for section markers and field documentation. For inline section comments within methods, consider using double slashes for consistency, or establish a clear convention.

Copilot uses AI. Check for mistakes.
skippedCount++;
}

/// 배치 간 대기 (스레드 풀 여유 확보)
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

[nitpick] This comment uses triple slashes (///) which is inconsistent with the single-line comment style used in line 167 of the same method. The codebase consistently uses triple slashes for section markers and field documentation. For inline section comments within methods, consider using double slashes for consistency, or establish a clear convention.

Copilot uses AI. Check for mistakes.
/// 배치 간 대기 (스레드 풀 여유 확보)
if (endIndex < activeUsers.size()) {
try {
TimeUnit.MILLISECONDS.sleep(100);
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

The hardcoded 100ms sleep duration should be extracted as a named constant (e.g., BATCH_DELAY_MILLIS) to improve maintainability and make the purpose clearer. This would also make it easier to tune the delay if needed.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants