What do you do when you get a failure during your DB Deployment?
First, let’s understand how Obevo behaves when exceptions occur. Then, let’s discuss the problem resolution options.
For each deployment activity, Obevo executes a set of changes. If a change is deployed successfully, then that status is marked in the DeployLog so that following deployments do not try to execute the same change.
For example:
We made special mention in that example that all those changes were in the same object. What if they were changes in different DB objects?
Replaying the example above from version 2:
Design note: There was some initial debate about this mode (the alternative is to just fail the whole deployment upon any exception); but there was a desire for this best-effort behavior as it made it easier and faster to resolve issues. The check to prevent successive changes within an object from proceeding was the safety feature that allowed the best-effort behavior to work well.
The above examples assume that each change C1, C2, ... can be executed atomically. It would be a problem if they weren’t. e.g.
This proves particularly interesting for DDL changes, as not all DBMS’s may be configured to allow transactional execution of DDLs. Hence, if you need to perform a set of actions on a particular object, you should attempt to break it up in as fine grained change statements as possible.
For example: instead of
//// CHANGE name=addColumns ALTER TABLE myTable ADD COLUMN col1 INT GO ALTER TABLE myTable ADD COLUMN col2 INT GO ALTER TABLE myTable ADD COLUMN col3 INT GO
do:
//// CHANGE name=addCol1 ALTER TABLE myTable ADD COLUMN col1 INT GO //// CHANGE name=addCol2 ALTER TABLE myTable ADD COLUMN col2 INT GO //// CHANGE name=addCol3 ALTER TABLE myTable ADD COLUMN col3 INT GO
Understandably, the finer-grained the changes are, the more clutter that would exist in your code. This is the trade-off that you should think about. With Obevo, we strove to make it as easy as possible to split it up without too much clutter. (e.g. at least you can split this changes within the same file using some text syntax, instead of having to keep them in separate files as other DB Deployment tools may have you do)
Now that we understand how Obevo behaves when encountering errors, here is guidance on how you should handle errors as a user
Start w/ analyzing the exception message. Most databases will give error messages with a code and a message; use those as hints. e.g. googling "db2 error code[yourErrorCode]" will usually find you a page linking to the error description on IBM’s page.
Once you’ve diagnosed an issue, you have a couple options:
At times, the error may be environmental and not something controllable from your DB code, e.g. users/groups not having been setup correctly, running out of disk space, and so on.
In such cases, fix the underlying issue and rerun the deployment. Per the Error Handling behavior description above, the deployment will pick up where it left off.
If this happens to fix the issue, then great. Otherwise, we move on to Option 2
This deserves its own page - see the Rollback Page for more information.