Upgrade getting failed when "output" folder is not present under ZIA directory when migrating to 13005 or above

Upgrade getting failed when "output" folder is not present under ZIA directory when migrating to 13005 or above

Issue:

In the issue fix SD-101380, the AI_DEFAULTMODEL table is removed. That table will be holding the default trained model IDs of Zia Approval Prediciton and the actual models will be stored physically under "<Installation Directory>/ServiceDesk/ZIA/output" folder. Since the table is getting dropped, the models should also be deleted in the mentioned directory and the fix was made accordingly.
      There is a case where customer may disabled all the Zia Prediction and took a backup and restored it in a setup and used it for production. In this scenario, there will be a row present in AI_DEFAULTMODEL for the previously used model during backup and it will be persisted again in restore. The output folder of the ZIA directory will not be taken during backup and new models will be created during startup after restore only if predictions are enabled. 
      So when migrating to the versions which has my SD-101380 fix (13005 and above), it will try to delete all the model files inside output directory which are found in AI_DEFAULTMODEL table but in the above case 'output' directory will not be present which led to NPE during upgrade.

Note: The below issue will occur only when the output folder is not present under "<Installation Directory>/ServiceDesk/ZIA" folder.

Reference Support Tickets:


Error Trace:

Jun 28, 2022 7:01:35 AM  [com.adventnet.persistence.SDPDDChangeListener]  [INFO] :  Post Invoke For Alter Table  Arc_ApprovalDetails finished here
Jun 28, 2022 7:01:35 AM  [com.adventnet.persistence.migration.MigrationUtil]  [INFO] : Going to execute query ::  DROP TABLE "AI_DefaultModel"
Jun 28, 2022 7:01:35 AM  [com.adventnet.persistence.migration.MigrationUtil]  [INFO] : Invoking PreListener
Jun 28, 2022 7:01:35 AM  [com.adventnet.persistence.SDPDDChangeListener]  [INFO] : 
Pre Invoke For Drop Table 
Jun 28, 2022 7:01:35 AM  [com.adventnet.persistence.migration.MigrationUtil]  [INFO] : Exception occured while executing...
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : java.lang.NullPointerException
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.persistence.SDPDDChangeUtil.deleteDefaultZiaModel(SDPDDChangeUtil.java:457)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.persistence.SDPDDChangeListener.preInvokeForDropTable(SDPDDChangeListener.java:154)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.persistence.migration.MigrationUtil.executeQuery(MigrationUtil.java:444)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.persistence.migration.MigrationUtil.applyDDLChanges(MigrationUtil.java:118)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.persistence.migration.MigrationUtil.applyDDLChanges(MigrationUtil.java:90)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.persistence.migration.MigrationUtil.applyDDLChanges(MigrationUtil.java:231)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.persistence.DefaultPostProcessor.updateDDs(DefaultPostProcessor.java:649)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.zoho.iam.migration.IAMPostProcessor.updateDDs(IAMPostProcessor.java:30)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.zoho.mickeyclient.migration.MickeyClientPostProcessor.updateDDs(MickeyClientPostProcessor.java:156)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.manageengine.servicedesk.updatemgr.util.ESMPostProcessor.updateDDs(ESMPostProcessor.java:64)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.persistence.DefaultPostProcessor.installPatch(DefaultPostProcessor.java:2170)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.zoho.mickeyclient.migration.MickeyClientPostProcessor.installPatch(MickeyClientPostProcessor.java:193)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.servicedesk.updatemgr.util.SDPostProcessor.installPatch(SDPostProcessor.java:85)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.persistence.DefaultPostProcessor.install(DefaultPostProcessor.java:1469)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at java.lang.reflect.Method.invoke(Method.java:498)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.tools.update.installer.Unzipper.contextPostInstallation(Unzipper.java:1716)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.tools.update.installer.Unzipper.invokePostInstallationClasses(Unzipper.java:1505)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.tools.update.installer.ApplyPatch.installPatch(ApplyPatch.java:492)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at com.adventnet.tools.update.installer.ApplyPatch.run(ApplyPatch.java:293)
Jun 28, 2022 7:01:35 AM  [SYSERR]  [INFO] : at java.lang.Thread.run(Thread.java:748)
Jun 28, 2022 7:01:35 AM  [com.adventnet.persistence.migration.MigrationUtil]  [INFO] : 
Going to revert


Workaround 1:
 Please follow the below steps:
-> Connect to the database.
-> Execute the below query:
delete from ai_defaultmodel;

Workaround 2:
Please follow the below steps:
-> Go to "<Installation Directory>/ServiceDesk/ZIA" folder
-> Create "output" folder inside it.

After trying the workaroud, now try to upgrade to 13005 or above.

Issue ID: SD-103532

                  New to ADSelfService Plus?

                    • Related Articles

                    • Zia Prerequesite when upgrading from version 14200 to 14300

                      Issue: Upgrade failed in Linux - ubuntu The GLIBC version should be 2.14 or higher and the versions below 2.14 will face the upgrade failure. Error: Workaround: Step 1: Please run the below queries in the report one by one by navigating to Reports >> ...
                    • Zia-prerequisites

                      Dear Users, From Supportcenter Plus build 14300, if you are using Windows OS and, Visual C++ 2019 (or higher) Redistributable is not installed on your machine, Zia Approval / Request Reopen / Category & Template Prediction will be disabled by ...
                    • Zia-prerequisites

                      Dear Users, From ServiceDeskPlus MSP build 14300, if you are using Windows OS and, Visual C++ 2019 (or higher) Redistributable is not installed on your machine, Zia Approval / Request Reopen / Category & Template Prediction will be disabled by ...
                    • ZIA: Signature removal Issue in builds >=14202 (XGBoost algorithm)

                      Issue: Zia Reopen prediction fails because it is predicting the signature content of an email rather than the description. Fix: The greetings (hi, hello, dear, etc) and email labels (ServiceDesk\ZIA\resources\signature_removal\outlookHandler.txt) are ...
                    • Error - Sanity Failed - Upgrade from 8121 to 11

                      While upgrading from 8121 to 11, after executing Updatemanager.bat and if the update fails, You need to check the Updatemanager logs in the path < Support Center Plus Application path -> Server-> Default-> Logs > .  And if you find the below ...