Skip to content

Commit

Permalink
only do sqlite stuff if leader
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Dec 12, 2023
1 parent 10ec7ce commit c1afa7f
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions migration_scripts/import_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,21 @@ rm -rf /home/pioreactor/.pioreactor/
# create the new .pioreactor/
tar -xzf $ARCHIVE_NAME

# rename the sqlite .backup
mv /home/pioreactor/.pioreactor/storage/pioreactor.sqlite.backup /home/pioreactor/.pioreactor/storage/pioreactor.sqlite
touch /home/pioreactor/.pioreactor/storage/pioreactor.sqlite-shm
touch /home/pioreactor/.pioreactor/storage/pioreactor.sqlite-wal

# check integrity, quickly
DB_CHECK=$(sqlite3 /home/pioreactor/.pioreactor/storage/pioreactor.sqlite "PRAGMA quick_check;")
if [[ "$DB_CHECK" != "ok" ]]; then
echo "Database integrity check failed: $DB_CHECK"
exit 1

leader_hostname=$(crudini --get /home/pioreactor/.pioreactor/config.ini cluster.topology leader_hostname)

if [ "$leader_hostname" = "$CURRENT_HOSTNAME" ]; then
# rename the sqlite .backup, if leader
mv /home/pioreactor/.pioreactor/storage/pioreactor.sqlite.backup /home/pioreactor/.pioreactor/storage/pioreactor.sqlite
touch /home/pioreactor/.pioreactor/storage/pioreactor.sqlite-shm
touch /home/pioreactor/.pioreactor/storage/pioreactor.sqlite-wal

# check integrity, quickly
DB_CHECK=$(sqlite3 /home/pioreactor/.pioreactor/storage/pioreactor.sqlite "PRAGMA quick_check;")
if [[ "$DB_CHECK" != "ok" ]]; then
echo "Database integrity check failed: $DB_CHECK"
fi

fi

# confirm permissions
Expand Down

0 comments on commit c1afa7f

Please sign in to comment.