백엔드 재시작 후 차트 2개 봉만 표시되는 race-condition 수정
HistoricalDataService.getHistory: 인메모리 봉이 20개 미만이면 Upbit REST 폴백을 실행하도록 변경. 이전 동작: rawBars.isEmpty() 일 때만 Upbit 폴백 → 재시작 직후 warm-up 미완료 상태에서 2~3개 봉이 메모리에 있으면 inMemory=true로 판정 후 Upbit 폴백 없이 2~3개 봉만 반환됨 수정 동작: rawBars.size() < 20 이면 Upbit REST 재조회 → warm-up 완료 전에도 최소 200개 봉을 반환 보장 → 차트 2개 캔들 표시 및 OBV plot1 누락 경고 해소 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -81,9 +81,17 @@ public class HistoricalDataService {
|
||||
rawBars = sliceFromMemory(market, candleType, toTime, safeCount);
|
||||
}
|
||||
|
||||
if (rawBars.isEmpty()) {
|
||||
log.debug("[HistoricalDataService] 업비트 REST 프록시: {} / {} / to={}", market, candleType, to);
|
||||
rawBars = fetchFromUpbit(market, candleType, to, safeCount);
|
||||
// 인메모리 봉이 최소 임계치(20개) 미만이면 Upbit REST 로 재조회.
|
||||
// 백엔드 재시작 직후 warm-up 미완료 상태에서 2~3개 봉만 반환되는
|
||||
// race-condition 을 방지한다.
|
||||
final int MIN_BARS_THRESHOLD = 20;
|
||||
if (rawBars.size() < Math.min(MIN_BARS_THRESHOLD, safeCount)) {
|
||||
log.info("[HistoricalDataService] 인메모리 봉 부족({}) → 업비트 REST 프록시: {} / {}",
|
||||
rawBars.size(), market, candleType);
|
||||
List<UpbitCandleRaw> upbitBars = fetchFromUpbit(market, candleType, to, safeCount);
|
||||
if (upbitBars.size() > rawBars.size()) {
|
||||
rawBars = upbitBars;
|
||||
}
|
||||
}
|
||||
|
||||
if (rawBars.isEmpty()) return Collections.emptyList();
|
||||
|
||||
Reference in New Issue
Block a user