Skip to content

Commit

Permalink
Resurrect archive only if it will be reused (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
sivanov-nuodb authored Nov 29, 2021
1 parent b330f6b commit 185ccb8
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions stable/database/files/nuosm
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,15 @@ function isRestoreSourceAvailable() {
#
function resurrectRemovedArchive() {
trace "resurrecting removed archive metadata"
# Find archiveId associated with process which address is the same as this pod hostname
# It assumes that there is only one archive object associated with the current host
removed_archive=$( nuocmd show archives --db-name $DB_NAME --removed --removed-archive-format "archive-id: {id}" | sed -En "/^archive-id: / {N; /$HOSTNAME/ s/^archive-id: ([0-9]+).*$/\1/; T; p}" | head -n 1 )
if [ -n "$removed_archive" ]; then
log "Resurrecting removed archiveId=${removed_archive}"
nuocmd create archive --db-name $DB_NAME --archive-path $DB_DIR --is-external --restored --archive-id $removed_archive
# Resurrect the previously fetched archiveId associated which this Pod it is
# removed
if [ -n "$myArchive" ] && \
nuocmd show archives \
--db-name $DB_NAME \
--removed \
--removed-archive-format "archive-id: {id}" | grep -q "archive-id: ${myArchive}$"; then
log "Resurrecting removed archiveId=${myArchive}"
nuocmd create archive --db-name $DB_NAME --archive-path $DB_DIR --is-external --restored --archive-id "$myArchive"
fi
}

Expand Down Expand Up @@ -761,9 +764,10 @@ else

wotIdid=""

# resurrect my archive if it is removed
# this will likely never execute but is kept to be sure
resurrectRemovedArchive
# resurrect my archive only if info.json file is available, otherwise
# nuodocker will create a new one; this is needed because KAA will remove
# archives for scaled down SM statefulsets
[ -f "$DB_DIR/info.json" ] && resurrectRemovedArchive

# if a RESTORE_SOURCE is defined, and the archive dir is empty, then import/restore from the URL
if [ -n "$restore_source" -a -z "$restore_requested" -a $atomCount -lt 20 -a $catalogCount -lt 2 ]; then
Expand Down

0 comments on commit 185ccb8

Please sign in to comment.