https://jira.atlassian.com/browse/CONF-13798
We met the exact issue trying to prevented by above ticket.
After we upgrade to 5.1.2, confluence failed to start up and shows the version of home directory does not match the database version.
The home directory version is: 3396, and the database version is: 4216.
Not sure what we could next to continue the upgrade...