You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by ml...@apache.org on 2015/12/21 04:05:21 UTC

incubator-hawq git commit: HAWQ-255: change CHECKPOINT_START_LOCK to a fine grained scope so that checkpoint not blocked.

Repository: incubator-hawq
Updated Branches:
  refs/heads/master 8239cb9a1 -> dc731e6e2


HAWQ-255: change CHECKPOINT_START_LOCK to a fine grained scope so that checkpoint not blocked.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/dc731e6e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/dc731e6e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/dc731e6e

Branch: refs/heads/master
Commit: dc731e6e26ab6e3a9d160fce5ee335d358056224
Parents: 8239cb9
Author: Ming LI <ml...@pivotal.io>
Authored: Tue Dec 15 19:04:10 2015 +0800
Committer: Ming LI <ml...@pivotal.io>
Committed: Mon Dec 21 11:03:56 2015 +0800

----------------------------------------------------------------------
 src/backend/access/transam/xact.c         | 43 ++++++++++----------------
 src/backend/cdb/cdbpersistentfilesysobj.c | 19 ------------
 src/backend/storage/buffer/bufmgr.c       |  8 -----
 src/backend/storage/lmgr/lmgr.c           | 24 --------------
 src/backend/storage/smgr/smgr.c           | 24 --------------
 src/include/storage/lmgr.h                |  4 ---
 6 files changed, 17 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/dc731e6e/src/backend/access/transam/xact.c
----------------------------------------------------------------------
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index fda64bd..784e883 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -2317,14 +2317,14 @@ CommitTransaction(void)
 	willHaveObjectsFromSmgr =
 			PersistentEndXactRec_WillHaveObjectsFromSmgr(EndXactRecKind_Commit);
 
-	if (willHaveObjectsFromSmgr)
-	{
-		/*
-		 * We need to ensure the recording of the [distributed-]commit record and the
-		 * persistent post-commit work will be done either before or after a checkpoint.
-		 */
-		CHECKPOINT_START_LOCK;
-	}
+	/* In previous version, we ensured the recording of the [distributed-]commit record and the
+	 * persistent post-commit work will be done either before or after a checkpoint.
+	 *
+	 * However the persistent table status will be synchronized with AOSeg_XXXX
+	 * table and hdfs file in PersistentRecovery_Scan() at recovery PASS2.
+	 * We don't need to worry about inconsistent states between them. So no
+	 * CHECKPOINT_START_LOCK any more.
+	 */
 
 	/* Prevent cancel/die interrupt while cleaning up */
 	HOLD_INTERRUPTS();
@@ -2426,11 +2426,6 @@ CommitTransaction(void)
 	 */
 	AtEOXact_smgr(true);
 
-	if (willHaveObjectsFromSmgr)
-	{
-		CHECKPOINT_START_UNLOCK;
-	}
-	
 	AtEOXact_MultiXact();
 
 	ResourceOwnerRelease(TopTransactionResourceOwner,
@@ -2809,14 +2804,15 @@ AbortTransaction(void)
 	willHaveObjectsFromSmgr =
 			PersistentEndXactRec_WillHaveObjectsFromSmgr(EndXactRecKind_Abort);
 
-	if (willHaveObjectsFromSmgr)
-	{
-		/*
-		 * We need to ensure the recording of the abort record and the
-		 * persistent post-abort work will be done either before or after a checkpoint.
-		 */
-		CHECKPOINT_START_LOCK;
-	}
+
+	/* In previous version, we ensured the recording of the the abort record and the
+	 * persistent post-abort work will be done either before or after a checkpoint.
+	 *
+	 * However the persistent table status will be synchronized with AOSeg_XXXX
+	 * table and hdfs file in PersistentRecovery_Scan() at recovery PASS2.
+	 * We don't need to worry about inconsistent states between them. So no
+	 * CHECKPOINT_START_LOCK any more.
+	 */
 
 	/*
 	 * Advertise the fact that we aborted in pg_clog (assuming that we got as
@@ -2869,11 +2865,6 @@ AbortTransaction(void)
 	AtEOXact_Inval(false);
 	AtEOXact_QueryContext();
 	AtEOXact_smgr(false);
-
-	if (willHaveObjectsFromSmgr)
-	{
-		CHECKPOINT_START_UNLOCK;
-	}
 	
 	AtEOXact_MultiXact();
 	ResourceOwnerRelease(TopTransactionResourceOwner,

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/dc731e6e/src/backend/cdb/cdbpersistentfilesysobj.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbpersistentfilesysobj.c b/src/backend/cdb/cdbpersistentfilesysobj.c
index 1f0b6f7..77ae62c 100644
--- a/src/backend/cdb/cdbpersistentfilesysobj.c
+++ b/src/backend/cdb/cdbpersistentfilesysobj.c
@@ -2120,18 +2120,6 @@ void PersistentFileSysObj_EndXactDrop(
 
 	bool					ignoreNonExistence)
 {
-	// NOTE: The caller must already have the MirroredLock.
-
-	if (fsObjName->type == PersistentFsObjType_RelationFile)
-	{
-		/*
-		 * We use this lock to guard data resynchronization.
-		 */
-		LockRelationForResynchronize(
-						PersistentFileSysObjName_GetRelFileNodePtr(fsObjName),
-						AccessExclusiveLock);
-	}
-
 	PersistentFileSysObj_DropObject(
 							fsObjName,
 							relStorageMgr,
@@ -2141,13 +2129,6 @@ void PersistentFileSysObj_EndXactDrop(
 							ignoreNonExistence,
 							Debug_persistent_print,
 							Persistent_DebugPrintLevel());
-
-	if (fsObjName->type == PersistentFsObjType_RelationFile)
-	{
-		UnlockRelationForResynchronize(
-						PersistentFileSysObjName_GetRelFileNodePtr(fsObjName),
-						AccessExclusiveLock);
-	}
 }
 
 void PersistentFileSysObj_UpdateRelationBufpoolKind(

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/dc731e6e/src/backend/storage/buffer/bufmgr.c
----------------------------------------------------------------------
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index 20fad10..fda45bb 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -2464,8 +2464,6 @@ RelationTruncate(Relation rel, BlockNumber nblocks, bool markPersistentAsPhysica
 
 	if (markPersistentAsPhysicallyTruncated)
 	{
-		LockRelationForResynchronize(&rel->rd_node, AccessExclusiveLock);
-
 		/*
 		 * Fetch gp_persistent_relation_node information so we can mark the persistent entry.
 		 */
@@ -2522,12 +2520,6 @@ RelationTruncate(Relation rel, BlockNumber nblocks, bool markPersistentAsPhysica
 
 	}
 
-	// -------- MirroredLock ----------
-	
-	if (markPersistentAsPhysicallyTruncated)
-	{
-		UnlockRelationForResynchronize(&rel->rd_node, AccessExclusiveLock);
-	}
 }
 
 /* ---------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/dc731e6e/src/backend/storage/lmgr/lmgr.c
----------------------------------------------------------------------
diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c
index b742e4d..3e699ed 100644
--- a/src/backend/storage/lmgr/lmgr.c
+++ b/src/backend/storage/lmgr/lmgr.c
@@ -339,30 +339,6 @@ UnlockRelationForResyncExtension(RelFileNode *relFileNode, LOCKMODE lockmode)
 	LockRelease(&tag, lockmode, false);
 }
 
-void
-LockRelationForResynchronize(RelFileNode *relFileNode, LOCKMODE lockmode)
-{
-	LOCKTAG		tag;
-
-	SET_LOCKTAG_RELATION_RESYNCHRONIZE(tag,
-						 relFileNode->dbNode,
-						 relFileNode->relNode);
-
-	LockAcquire(&tag, lockmode, false, false);
-}
-
-void
-UnlockRelationForResynchronize(RelFileNode *relFileNode, LOCKMODE lockmode)
-{
-	LOCKTAG		tag;
-
-	SET_LOCKTAG_RELATION_RESYNCHRONIZE(tag,
-						 relFileNode->dbNode,
-						 relFileNode->relNode);
-
-	LockRelease(&tag, lockmode, false);
-}
-
 LockAcquireResult
 LockRelationAppendOnlySegmentFile(RelFileNode *relFileNode, int32 segno, LOCKMODE lockmode, bool dontWait)
 {

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/dc731e6e/src/backend/storage/smgr/smgr.c
----------------------------------------------------------------------
diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c
index f47fa4f..b51cd83 100644
--- a/src/backend/storage/smgr/smgr.c
+++ b/src/backend/storage/smgr/smgr.c
@@ -1327,28 +1327,6 @@ smgrDoDeleteActions(
 						palloc0((*listCount) * sizeof(PersistentFileSysObjStateChangeResult));
 
 	/*
-	 * There are two situations where we get here. CommitTransaction()/AbortTransaction() or via
-	 * AbortSubTransaction(). In the first case, we have already obtained the MirroredLock and
-	 * CheckPointStartLock. In the second case, we have not obtained the locks, so we attempt
-	 * to get them to make sure proper lock order is maintained.
-	 *
-	 * Normally, if a relation lock is needed, it is obtained before the MirroredLock and CheckPointStartLock,
-	 * but we have not yet obtained an EXCLUSIVE LockRelationForResynchronize. This lock will be obtained in
-	 * PersistentFileSysObj_EndXactDrop(). This is an exception to the normal lock ordering, which is done
-	 * to reduce the time that the lock is held, thus allowing a larger window of time for filerep
-	 * resynchronization to obtain the lock.
-	 */
-
-	/*
-	 * The logic will eventually obtain a CheckpointStartLock in PersistentRelation_Dropped(),
-	 * but functions called from this function my obtain Exclusive locks before the
-	 * CheckpointStartLock is obtained. This could cause a potential deadlock in the future.
-	 * We need to take a CheckpointStartLock here to maintain proper lock ordering
-	 * (i.e. MirrorLock -> CheckpointStartLock ).
-	 */
-	CHECKPOINT_START_LOCK;
-
-	/*
 	 * First pass does the initial State-Changes.
 	 */
 	entryIndex = 0;
@@ -1608,8 +1586,6 @@ smgrDoDeleteActions(
 
 	PersistentFileSysObj_FlushXLog();
 
-	CHECKPOINT_START_UNLOCK;
-
 	if (stateChangeResults != NULL)
 		pfree(stateChangeResults);
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/dc731e6e/src/include/storage/lmgr.h
----------------------------------------------------------------------
diff --git a/src/include/storage/lmgr.h b/src/include/storage/lmgr.h
index 73448a6..22dbdb2 100644
--- a/src/include/storage/lmgr.h
+++ b/src/include/storage/lmgr.h
@@ -42,10 +42,6 @@ extern void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode);
 extern void LockRelationForResyncExtension(RelFileNode *relFileNode, LOCKMODE lockmode);
 extern void UnlockRelationForResyncExtension(RelFileNode *relFileNode, LOCKMODE lockmode);
 
-/* Lock a relation for resynchronize */
-extern void LockRelationForResynchronize(RelFileNode *relFileNode, LOCKMODE lockmode);
-extern void UnlockRelationForResynchronize(RelFileNode *relFileNode, LOCKMODE lockmode);
-
 /* Lock a relation for Append-Only segment files. */
 extern LockAcquireResult LockRelationAppendOnlySegmentFile(RelFileNode *relFileNode, int32 segno, LOCKMODE lockmode, bool dontWait);
 extern void UnlockRelationAppendOnlySegmentFile(RelFileNode *relFileNode, int32 segno, LOCKMODE lockmode, int32 contentid);