44 lines
1.1 KiB
Plaintext
44 lines
1.1 KiB
Plaintext
@startuml fig_35_sync_merge_algorithm
|
||
!include _gost-theme.inc.puml
|
||
scale 2.5
|
||
|
||
start
|
||
|
||
:Группа Storage (≥ 2 UUID из DbStorageSyncGroup);
|
||
:Захват блокировок sync (lease);
|
||
:Параллельно: flush + readSyncJournal
|
||
для каждого Storage;
|
||
|
||
partition "Слияние (StorageSyncJournalMerge)" {
|
||
:Для каждого пути — запись
|
||
с максимальной ревизией;
|
||
note right
|
||
compare: sequence → actorId → createdAt
|
||
end note
|
||
}
|
||
|
||
while (Есть необработанный путь?) is (да)
|
||
:winnerEntry = победитель по пути;
|
||
:sourceStorage = findSourceStorage(winnerEntry);
|
||
if (operation == UPSERT
|
||
и source == null?) then (да)
|
||
:пропуск пути;
|
||
else (нет)
|
||
while (Есть target Storage?) is (да)
|
||
if (ревизия target ≥ winner?) then (да)
|
||
:пропуск target;
|
||
else (нет)
|
||
:applyEntry:
|
||
UPSERT — copy stream
|
||
DELETE/TRASH — на target
|
||
(recordSyncJournal = false);
|
||
endif
|
||
endwhile (нет)
|
||
endif
|
||
endwhile (нет)
|
||
|
||
:Снятие блокировок;
|
||
stop
|
||
|
||
@enduml
|