Eli Mesika has uploaded a new change for review. Change subject: core:remove storage pool is failing in Psql exception... ......................................................................
core:remove storage pool is failing in Psql exception... ovirt-engine: remove storage pool is failing in Psql exception: Failed to run compensation on startup for Command org.ovirt.engine.core.bll.storage.RemoveStoragePoolCommand, Com mand Id : 076abb88-ead3-4a87-9d31-a534f41ad127, due to: DataIntegrityViolatio Since there may be some compensation entries that are not related to Zombie tasks left and this may cause the backend to abort when trying to activate the compensation procedure on system startup. This patch adds a -A flag to taskcleaner utility that enable to remove all compensation data from the business_entity_snapshot table. Installer should call taskcleaner with the -A flag. instead of running taskcleaner with -zRCJq flags, installer should invoke taskcleaner with the -zRAq flags Change-Id: Iea501a3da1b0fe72b4c4e95b751d51cd6efb7843 Bug-Url: https://bugzilla.redhat.com/921202 Signed-off-by: Eli Mesika <emes...@redhat.com> --- M backend/manager/tools/dbutils/taskcleaner.sh M backend/manager/tools/dbutils/taskcleaner_sp.sql 2 files changed, 53 insertions(+), 26 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/10/13110/1 diff --git a/backend/manager/tools/dbutils/taskcleaner.sh b/backend/manager/tools/dbutils/taskcleaner.sh index bb99d0a..e2ceafe 100755 --- a/backend/manager/tools/dbutils/taskcleaner.sh +++ b/backend/manager/tools/dbutils/taskcleaner.sh @@ -25,7 +25,7 @@ set_defaults usage() { - printf "Usage: ${ME} [-h] [-s server] [-p PORT]] [-d DATABASE] [-u USERNAME] [-l LOGFILE] [-t taskId] [-c commandId] [-z] [-R] [-C] [-J] [-q] [-v]\n" + printf "Usage: ${ME} [-h] [-s server] [-p PORT]] [-d DATABASE] [-u USERNAME] [-l LOGFILE] [-t taskId] [-c commandId] [-z] [-R] [-C] [-J] [-A] [-q] [-v]\n" printf "\n" printf "\t-s SERVERNAME - The database servername for the database (def. ${SERVERNAME})\n" printf "\t-p PORT - The database port for the database (def. ${PORT})\n" @@ -38,6 +38,7 @@ printf "\t-R - Removes all Zombie tasks.\n" printf "\t-C - Clear related compensation entries.\n" printf "\t-J - Clear related Job Steps.\n" + printf "\t-A - Clear all Job Steps and compensation entries.\n" printf "\t-q - Quite mode, do not prompt for confirmation.\n" printf "\t-v - Turn on verbosity (WARNING: lots of output)\n" printf "\t-h - This help text.\n" @@ -62,10 +63,11 @@ CLEAR_ALL=false CLEAR_COMPENSATION=false CLEAR_JOB_STEPS=false +CLEAR_JOB_STEPS_AND_COMPENSATION=false QUITE_MODE=false FIELDS="task_id,task_type,status,started_at,result,action_type as command_type,command_id,step_id,storage_pool_id as DC" -while getopts hs:d:u:p:l:t:c:zRCJqv option; do +while getopts hs:d:u:p:l:t:c:zRCJAqv option; do case $option in s) SERVERNAME=$OPTARG;; p) PORT=$OPTARG;; @@ -78,6 +80,7 @@ R) CLEAR_ALL=true;; C) CLEAR_COMPENSATION=true;; J) CLEAR_JOB_STEPS=true;; + A) CLEAR_JOB_STEPS_AND_COMPENSATION=true;; q) QUITE_MODE=true;; v) VERBOSE=true;; h) ret=0 && usage;; @@ -187,38 +190,48 @@ elif [ "${CLEAR_ALL}" = "true" ]; then if [ "${ZOMBIES_ONLY}" = "true" ]; then CMD2="SELECT DeleteAsyncTasksZombies();" - if [ "${CLEAR_COMPENSATION}" = "true" ]; then - CMD1="${CMD1}SELECT DeleteEntitySnapshotZombies();" - if [ "${CLEAR_JOB_STEPS}" = "true" ]; then - caution "This will remove all Zombie Tasks in async_tasks table, its related Job Steps and Compensation data!!!" - CMD1="${CMD1}SELECT DeleteJobStepsZombies();" - else - caution "This will remove all Zombie Tasks in async_tasks table and its related Compensation data!!!" - fi + if [ "${CLEAR_JOB_STEPS_AND_COMPENSATION}" = "true" ]; then + caution "This will remove all Zombie Tasks in async_tasks table, and all Job Steps and Compensation data!!!" + CMD1="SELECT DeleteAllJobs(); SELECT DeleteAllEntitySnapshot();" else - if [ "${CLEAR_JOB_STEPS}" = "true" ]; then - caution "This will remove all Zombie Tasks in async_tasks table and its related Job Steps!!!" - CMD1="${CMD1}SELECT DeleteJobStepsZombies();" + if [ "${CLEAR_COMPENSATION}" = "true" ]; then + CMD1="${CMD1}SELECT DeleteEntitySnapshotZombies();" + if [ "${CLEAR_JOB_STEPS}" = "true" ]; then + caution "This will remove all Zombie Tasks in async_tasks table, its related Job Steps and Compensation data!!!" + CMD1="${CMD1}SELECT DeleteJobStepsZombies();" + else + caution "This will remove all Zombie Tasks in async_tasks table and its related Compensation data!!!" + fi else - caution "This will remove all Zombie Tasks in async_tasks table!!!" + if [ "${CLEAR_JOB_STEPS}" = "true" ]; then + caution "This will remove all Zombie Tasks in async_tasks table and its related Job Steps!!!" + CMD1="${CMD1}SELECT DeleteJobStepsZombies();" + else + caution "This will remove all Zombie Tasks in async_tasks table!!!" + fi fi fi else CMD2="TRUNCATE TABLE async_tasks cascade;" - if [ "${CLEAR_COMPENSATION}" = "true" ]; then - CMD1="TRUNCATE TABLE business_entity_snapshot cascade;" - if [ "${CLEAR_JOB_STEPS}" = "true" ]; then - caution "This will remove all Tasks in async_tasks table, its related Job Steps and Compensation data!!!" - CMD1="${CMD1}TRUNCATE TABLE step cascade;" - else - caution "This will remove all async_tasks table content and its related Compensation data!!!" - fi + if [ "${CLEAR_JOB_STEPS_AND_COMPENSATION}" = "true" ]; then + caution "This will remove all Tasks in async_tasks table, and all Job Steps and Compensation data!!!" + CMD1="SELECT DeleteAllJobs(); SELECT DeleteAllEntitySnapshot();" else - if [ "${CLEAR_JOB_STEPS}" = "true" ]; then - caution "This will remove all Tasks in async_tasks table and its related Job Steps!!!" - CMD1="${CMD1}TRUNCATE TABLE step cascade;" + if [ "${CLEAR_COMPENSATION}" = "true" ]; then + CMD1="TRUNCATE TABLE business_entity_snapshot cascade;" + if [ "${CLEAR_JOB_STEPS}" = "true" ]; then + caution "This will remove all Tasks in async_tasks table, its related Job Steps and Compensation data!!!" + CMD1="${CMD1}TRUNCATE TABLE step cascade;" + else + caution "This will remove all async_tasks table content and its related Compensation data!!!" + fi else - caution "This will remove all async_tasks table content!!!" + if [ "${CLEAR_JOB_STEPS}" = "true" ]; then + caution "This will remove all Tasks in async_tasks table and its related Job Steps!!!" + CMD1="${CMD1}TRUNCATE TABLE step cascade;" + else + caution "This will remove all async_tasks table content!!!" + fi fi fi fi diff --git a/backend/manager/tools/dbutils/taskcleaner_sp.sql b/backend/manager/tools/dbutils/taskcleaner_sp.sql index d7c1bd5..bf90648 100644 --- a/backend/manager/tools/dbutils/taskcleaner_sp.sql +++ b/backend/manager/tools/dbutils/taskcleaner_sp.sql @@ -104,3 +104,17 @@ DELETE FROM step WHERE step_id IN (SELECT step_id FROM GetAsyncTasksZombies()); END; $procedure$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION DeleteAllJobs() RETURNS VOID + AS $procedure$ +BEGIN + DELETE FROM job; +END; $procedure$ +LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION DeleteAllEntitySnapshot() RETURNS VOID + AS $procedure$ +BEGIN + DELETE FROM business_entity_snapshot; +END; $procedure$ +LANGUAGE plpgsql; -- To view, visit http://gerrit.ovirt.org/13110 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iea501a3da1b0fe72b4c4e95b751d51cd6efb7843 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <emes...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches