Github user ChinmaySKulkarni commented on the issue: https://github.com/apache/phoenix/pull/295 @JamesRTaylor addressed review comments on ensureSystemTablesMigratedToSystemNamespace. Basically, now we return an UpgradeRequiredException even in the case that we need to migrate SYSTEM tables to the SYSTEM namespace. Just doing that was not sufficient since we would have to run 'EXECUTE UPGRADE' once for the migration and once for the upgrade (if required). So, to avoid this, I am storing the SYSCAT timestamp as part of the UpgradeRequiredException and I have separated the SYSCAT schema upgrade code to another method. Now we only acquire the SYSMUTEX lock once (1. if we need to just perform an upgrade OR 2. if we need to migrate SYSTEM tables to the SYSTEM namespace and/or also perform an upgrade). Added a test for this as well. Please let me know what you think about this approach. Thanks!
---