# javadoc 은 넣기를 upsert 로 정의한다 19: *
An enqueue is an upsert: the same file reported twice updates the open item rather than adding 20: * a second one. Reconciliation runs on a schedule and re-raises whatever it still cannot settle, so 21: * an append-only queue would grow one row per sweep per unresolved file and bury the distinct 22: * problems under repetitions of the same one. # 저장소 javadoc 은 최신 이유가 이긴다고 적는다 24: /** 25: * Re-raises an open item instead of adding a second one. 26: * 27: *
Reconciliation is retried on a schedule, so the same file reaches the queue repeatedly. One
28: * open item per file keeps the queue a worklist rather than a failure log; the newest reason wins
29: * because it describes the most recent evidence.
30: */
# 구현은 갱신하고, 0 이면 저장한다
42: @Override
43: public void enqueue(FileId fileId, String reasonCode) {
44: Instant now = clock.instant();
45: if (items.refreshPending(fileId.value(), reasonCode, now) > 0) {
46: return;
47: }
48: items.save(
49: new RecoveryItemEntity(UUID.randomUUID(), fileId.value(), reasonCode, STATUS_PENDING, now));
50: }
# 그 저장이 persist 로 갈지 merge 로 갈지 정하는 것
# 엔티티의 @Version 필드: 0
# Persistable 구현: 0
# 데이터베이스가 파일당 열린 항목을 하나로 강제한다
52--- At most one open item per file: the queue is a worklist, not a log of every sweep.
53:CREATE UNIQUE INDEX uq_fs_recovery_open
54- ON fs_recovery_item (file_id)
55- WHERE status = 'PENDING';
56-
# 호출자가 실제로 받는 예외
195: private Reservation is an {@code INSERT ... ON CONFLICT DO NOTHING} whose affected-row count is the
messaging/messaging-inbox-jdbc-postgresql/src/main/java/dev/caskeleton/messaging/inbox/JdbcInboxRepository.java:36: ON CONFLICT (message_id, consumer_id) DO NOTHING