提交 af8dc9c2 编写于 作者: J Jacob Champion 提交者: Xin Zhang

Add assert checking to "UnderLock" functions

Signed-off-by: NTaylor Vesely <tvesely@pivotal.io>
上级 677c3eac
...@@ -129,6 +129,8 @@ PersistentFilespace_FindDirUnderLock( ...@@ -129,6 +129,8 @@ PersistentFilespace_FindDirUnderLock(
FilespaceDirEntryKey key; FilespaceDirEntryKey key;
Assert(LWLockHeldByMe(FilespaceHashLock));
if (persistentFilespaceSharedHashTable == NULL) if (persistentFilespaceSharedHashTable == NULL)
elog(PANIC, "Persistent filespace information shared-memory not setup"); elog(PANIC, "Persistent filespace information shared-memory not setup");
...@@ -156,6 +158,8 @@ PersistentFilespace_CreateDirUnderLock( ...@@ -156,6 +158,8 @@ PersistentFilespace_CreateDirUnderLock(
FilespaceDirEntryKey key; FilespaceDirEntryKey key;
Assert(LWLockHeldByMe(FilespaceHashLock));
if (persistentFilespaceSharedHashTable == NULL) if (persistentFilespaceSharedHashTable == NULL)
elog(PANIC, "Persistent filespace information shared-memory not setup"); elog(PANIC, "Persistent filespace information shared-memory not setup");
...@@ -184,6 +188,8 @@ PersistentFilespace_RemoveDirUnderLock( ...@@ -184,6 +188,8 @@ PersistentFilespace_RemoveDirUnderLock(
{ {
FilespaceDirEntry removeFilespaceDirEntry; FilespaceDirEntry removeFilespaceDirEntry;
Assert(LWLockHeldByMe(FilespaceHashLock));
if (persistentFilespaceSharedHashTable == NULL) if (persistentFilespaceSharedHashTable == NULL)
elog(PANIC, "Persistent filespace information shared-memory not setup"); elog(PANIC, "Persistent filespace information shared-memory not setup");
......
...@@ -105,6 +105,8 @@ PersistentTablespace_FindEntryUnderLock( ...@@ -105,6 +105,8 @@ PersistentTablespace_FindEntryUnderLock(
TablespaceDirEntryKey key; TablespaceDirEntryKey key;
Assert(LWLockHeldByMe(TablespaceHashLock));
if (persistentTablespaceSharedHashTable == NULL) if (persistentTablespaceSharedHashTable == NULL)
elog(PANIC, "Persistent tablespace information shared-memory not setup"); elog(PANIC, "Persistent tablespace information shared-memory not setup");
...@@ -134,6 +136,8 @@ PersistentTablespace_CreateEntryUnderLock( ...@@ -134,6 +136,8 @@ PersistentTablespace_CreateEntryUnderLock(
TablespaceDirEntryKey key; TablespaceDirEntryKey key;
Assert(LWLockHeldByMe(TablespaceHashLock));
if (persistentTablespaceSharedHashTable == NULL) if (persistentTablespaceSharedHashTable == NULL)
elog(PANIC, "Persistent tablespace information shared-memory not setup"); elog(PANIC, "Persistent tablespace information shared-memory not setup");
...@@ -164,6 +168,8 @@ PersistentTablespace_RemoveEntryUnderLock( ...@@ -164,6 +168,8 @@ PersistentTablespace_RemoveEntryUnderLock(
{ {
TablespaceDirEntry removeTablespaceDirEntry; TablespaceDirEntry removeTablespaceDirEntry;
Assert(LWLockHeldByMe(TablespaceHashLock));
if (persistentTablespaceSharedHashTable == NULL) if (persistentTablespaceSharedHashTable == NULL)
elog(PANIC, "Persistent tablespace information shared-memory not setup"); elog(PANIC, "Persistent tablespace information shared-memory not setup");
...@@ -847,12 +853,7 @@ PersistentTablespace_RemoveSegment(int16 dbid, bool ismirror) ...@@ -847,12 +853,7 @@ PersistentTablespace_RemoveSegment(int16 dbid, bool ismirror)
WRITE_PERSISTENT_STATE_ORDERED_LOCK; WRITE_PERSISTENT_STATE_ORDERED_LOCK;
/* LWLockAcquire(TablespaceHashLock, LW_SHARED);
* Writes to the shared tablespace hash table are protected by
* PersistentObjLock, which is held at this point. The tablespace hash
* therefore, can be read without acquiring TablespaceHashLock because we
* are not making any change to the hash table in this function.
*/
while ((tablespaceDirEntry = hash_seq_search(&hstat)) != NULL) while ((tablespaceDirEntry = hash_seq_search(&hstat)) != NULL)
{ {
PersistentFileSysObjName fsObjName; PersistentFileSysObjName fsObjName;
...@@ -862,6 +863,8 @@ PersistentTablespace_RemoveSegment(int16 dbid, bool ismirror) ...@@ -862,6 +863,8 @@ PersistentTablespace_RemoveSegment(int16 dbid, bool ismirror)
tablespaceDirEntry = PersistentTablespace_FindEntryUnderLock(tblspc); tablespaceDirEntry = PersistentTablespace_FindEntryUnderLock(tblspc);
LWLockRelease(TablespaceHashLock);
if (tablespaceDirEntry == NULL) if (tablespaceDirEntry == NULL)
elog(ERROR, "Did not find persistent tablespace entry %u", elog(ERROR, "Did not find persistent tablespace entry %u",
tblspc); tblspc);
...@@ -876,7 +879,10 @@ PersistentTablespace_RemoveSegment(int16 dbid, bool ismirror) ...@@ -876,7 +879,10 @@ PersistentTablespace_RemoveSegment(int16 dbid, bool ismirror)
dbid, dbid,
ismirror, ismirror,
/* flushToXlog */ false); /* flushToXlog */ false);
LWLockAcquire(TablespaceHashLock, LW_SHARED);
} }
LWLockRelease(TablespaceHashLock);
WRITE_PERSISTENT_STATE_ORDERED_UNLOCK; WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册