提交 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(
FilespaceDirEntryKey key;
Assert(LWLockHeldByMe(FilespaceHashLock));
if (persistentFilespaceSharedHashTable == NULL)
elog(PANIC, "Persistent filespace information shared-memory not setup");
......@@ -156,6 +158,8 @@ PersistentFilespace_CreateDirUnderLock(
FilespaceDirEntryKey key;
Assert(LWLockHeldByMe(FilespaceHashLock));
if (persistentFilespaceSharedHashTable == NULL)
elog(PANIC, "Persistent filespace information shared-memory not setup");
......@@ -184,6 +188,8 @@ PersistentFilespace_RemoveDirUnderLock(
{
FilespaceDirEntry removeFilespaceDirEntry;
Assert(LWLockHeldByMe(FilespaceHashLock));
if (persistentFilespaceSharedHashTable == NULL)
elog(PANIC, "Persistent filespace information shared-memory not setup");
......
......@@ -105,6 +105,8 @@ PersistentTablespace_FindEntryUnderLock(
TablespaceDirEntryKey key;
Assert(LWLockHeldByMe(TablespaceHashLock));
if (persistentTablespaceSharedHashTable == NULL)
elog(PANIC, "Persistent tablespace information shared-memory not setup");
......@@ -134,6 +136,8 @@ PersistentTablespace_CreateEntryUnderLock(
TablespaceDirEntryKey key;
Assert(LWLockHeldByMe(TablespaceHashLock));
if (persistentTablespaceSharedHashTable == NULL)
elog(PANIC, "Persistent tablespace information shared-memory not setup");
......@@ -164,6 +168,8 @@ PersistentTablespace_RemoveEntryUnderLock(
{
TablespaceDirEntry removeTablespaceDirEntry;
Assert(LWLockHeldByMe(TablespaceHashLock));
if (persistentTablespaceSharedHashTable == NULL)
elog(PANIC, "Persistent tablespace information shared-memory not setup");
......@@ -847,12 +853,7 @@ PersistentTablespace_RemoveSegment(int16 dbid, bool ismirror)
WRITE_PERSISTENT_STATE_ORDERED_LOCK;
/*
* 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.
*/
LWLockAcquire(TablespaceHashLock, LW_SHARED);
while ((tablespaceDirEntry = hash_seq_search(&hstat)) != NULL)
{
PersistentFileSysObjName fsObjName;
......@@ -862,6 +863,8 @@ PersistentTablespace_RemoveSegment(int16 dbid, bool ismirror)
tablespaceDirEntry = PersistentTablespace_FindEntryUnderLock(tblspc);
LWLockRelease(TablespaceHashLock);
if (tablespaceDirEntry == NULL)
elog(ERROR, "Did not find persistent tablespace entry %u",
tblspc);
......@@ -876,7 +879,10 @@ PersistentTablespace_RemoveSegment(int16 dbid, bool ismirror)
dbid,
ismirror,
/* flushToXlog */ false);
LWLockAcquire(TablespaceHashLock, LW_SHARED);
}
LWLockRelease(TablespaceHashLock);
WRITE_PERSISTENT_STATE_ORDERED_UNLOCK;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册