Skip to content

Commit

Permalink
Use /dev/shm for the started marker file
Browse files Browse the repository at this point in the history
Because /dev/shm will be automatically wiped on container restarts.
  • Loading branch information
felipecrs committed Oct 21, 2024
1 parent 9f946bb commit 3c428ff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ENV ORACLE_BASE=/opt/oracle \
INSTALL_DB_BINARIES_FILE="installDBBinaries.sh" \
RELINK_BINARY_FILE="relinkOracleBinary.sh" \
CONFIG_TCPS_FILE="configTcps.sh" \
DB_STARTED_MARKER_FILE="/dev/shm/.db_started" \
SLIMMING=$SLIMMING \
ENABLE_ARCHIVELOG=false \
ARCHIVELOG_DIR_NAME=archive_logs \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ EOF
################ MAIN #######################
#############################################

if [ "${BYPASS_STARTED_MARKER:-false}" = false ] && [ ! -f /tmp/.oracle_database_started ]; then
echo "Database was not started yet" >&2
if [ "$IGNORE_DB_STARTED_MARKER" != true ] && [ ! -f "$DB_STARTED_MARKER_FILE" ]; then
echo "Database was not started yet." >&2
exit 1
fi

Expand Down
11 changes: 4 additions & 7 deletions OracleDatabase/SingleInstance/dockerfiles/21.3.0/runOracle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ EOF
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
###################################

# Marker file for the healthcheck
rm -f /tmp/.oracle_database_started

# Check whether container has enough memory
if [[ -f /sys/fs/cgroup/cgroup.controllers ]]; then
memory=$(cat /sys/fs/cgroup/memory.max)
Expand Down Expand Up @@ -283,7 +280,7 @@ else
"$ORACLE_BASE"/"$CREATE_DB_FILE" $ORACLE_SID "$ORACLE_PDB" "$ORACLE_PWD" || exit 1;

# Check whether database is successfully created
if BYPASS_STARTED_MARKER=true "$ORACLE_BASE"/"$CHECK_DB_FILE"; then
if IGNORE_DB_STARTED_MARKER=true "$ORACLE_BASE"/"$CHECK_DB_FILE"; then
# Create a checkpoint file if database is successfully created
# Populate the checkpoint file with the current date to avoid timing issue when using NFS persistence in multi-replica mode
echo "$(date -Iseconds)" > "$ORACLE_BASE"/oradata/.${ORACLE_SID}"${CHECKPOINT_FILE_EXTN}"
Expand All @@ -306,7 +303,7 @@ else
fi;

# Check whether database is up and running
BYPASS_STARTED_MARKER=true "$ORACLE_BASE"/"$CHECK_DB_FILE"
IGNORE_DB_STARTED_MARKER=true "$ORACLE_BASE"/"$CHECK_DB_FILE"
status=$?

# Check whether database is up and running
Expand All @@ -321,8 +318,8 @@ if [ $status -eq 0 ]; then
# Execute custom provided startup scripts
"$ORACLE_BASE"/"$USER_SCRIPTS_FILE" "$ORACLE_BASE"/scripts/startup

# Marker file for the healthcheck
touch /tmp/.oracle_database_started
# Create marker file for the healthcheck
touch "$DB_STARTED_MARKER_FILE"
else
echo "#####################################"
echo "########### E R R O R ###############"
Expand Down

0 comments on commit 3c428ff

Please sign in to comment.