TTL on UPGRADE_LOCK cell causes upgrade to fail
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/8a231a94 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/8a231a94 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/8a231a94 Branch: refs/heads/encodecolumns2 Commit: 8a231a94ceb07f8b3967a15bde07b694a92ae58e Parents: 96b6554 Author: Samarth <samarth.j...@salesforce.com> Authored: Mon Dec 12 12:01:38 2016 -0800 Committer: Samarth <samarth.j...@salesforce.com> Committed: Mon Dec 12 12:01:38 2016 -0800 ---------------------------------------------------------------------- .../phoenix/query/ConnectionQueryServicesImpl.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/8a231a94/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java index 9bc088d..c8d42d9 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java @@ -2997,8 +2997,20 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement Put put = new Put(rowToLock); put.add(family, qualifier, newValue); boolean acquired = sysMutexTable.checkAndPut(rowToLock, family, qualifier, oldValue, put); - if (!acquired) { throw new UpgradeInProgressException(getVersion(currentServerSideTableTimestamp), - getVersion(MIN_SYSTEM_TABLE_TIMESTAMP)); } + if (!acquired) { + /* + * Because of TTL on the SYSTEM_MUTEX_FAMILY, it is very much possible that the cell + * has gone away. So we need to retry with an old value of null. Note there is a small + * race condition here that between the two checkAndPut calls, it is possible that another + * request would have set the value back to UPGRADE_MUTEX_UNLOCKED. In that scenario this + * following checkAndPut would still return false even though the lock was available. + */ + acquired = sysMutexTable.checkAndPut(rowToLock, family, qualifier, null, put); + if (!acquired) { + throw new UpgradeInProgressException(getVersion(currentServerSideTableTimestamp), + getVersion(MIN_SYSTEM_TABLE_TIMESTAMP)); + } + } return true; } }