mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-17 21:20:37 +00:00
Address review comments
This commit is contained in:
committed by
Konstantin Knizhnik
parent
fb6d7c4676
commit
902ea0ccd9
@@ -331,15 +331,13 @@ typedef struct
|
||||
dlist_node lru_node; /* LRU list node */
|
||||
} RelKindEntry;
|
||||
|
||||
extern LWLockId finish_unlogged_build_lock;
|
||||
|
||||
extern void relkind_hash_init(void);
|
||||
extern void set_cached_relkind(NRelFileInfo rinfo, RelKind relkind);
|
||||
extern RelKind get_cached_relkind(NRelFileInfo rinfo);
|
||||
extern RelKindEntry* pin_cached_relkind(NRelFileInfo rinfo, RelKind relkind);
|
||||
extern void unpin_cached_relkind(RelKindEntry* entry);
|
||||
extern void fs_exclusive_lock(void);
|
||||
extern void fs_shared_lock(void);
|
||||
extern void fs_unlock(void);
|
||||
extern void forget_cached_relkind(NRelFileInfo rinfo);
|
||||
|
||||
#endif /* PAGESTORE_CLIENT_H */
|
||||
|
||||
@@ -1604,7 +1604,7 @@ neon_write(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const vo
|
||||
{
|
||||
XLogRecPtr lsn;
|
||||
RelKind relkind;
|
||||
bool fs_locked = false;
|
||||
bool is_locked = false;
|
||||
NRelFileInfo rinfo = InfoFromSMgrRel(reln);
|
||||
|
||||
switch (reln->smgr_relpersistence)
|
||||
@@ -1622,8 +1622,8 @@ neon_write(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const vo
|
||||
/* In case of unlogged build we need to avoid race condition at unlogged build end.
|
||||
* Obtain shared lock here to prevent backend completing unlogged build from performing cleanup amnd remvong files.
|
||||
*/
|
||||
fs_shared_lock();
|
||||
fs_locked = true;
|
||||
LWLockAcquire(finish_unlogged_build_lock, LW_SHARED);
|
||||
is_locked = true;
|
||||
/*
|
||||
* Recheck relkind under lock - may be unlogged build is already finished
|
||||
*/
|
||||
@@ -1637,9 +1637,9 @@ neon_write(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, const vo
|
||||
mdwrite(reln, forknum, blocknum, buffer, skipFsync);
|
||||
#endif
|
||||
}
|
||||
if (fs_locked)
|
||||
if (is_locked)
|
||||
{
|
||||
fs_unlock();
|
||||
LWLockRelease(finish_unlogged_build_lock);
|
||||
}
|
||||
if (relkind == RELKIND_UNLOGGED || relkind == RELKIND_UNLOGGED_BUILD)
|
||||
{
|
||||
@@ -1706,7 +1706,7 @@ neon_writev(SMgrRelation reln, ForkNumber forknum, BlockNumber blkno,
|
||||
{
|
||||
RelKind relkind;
|
||||
NRelFileInfo rinfo = InfoFromSMgrRel(reln);
|
||||
bool fs_locked = false;
|
||||
bool is_locked = false;
|
||||
switch (reln->smgr_relpersistence)
|
||||
{
|
||||
case 0:
|
||||
@@ -1722,8 +1722,8 @@ neon_writev(SMgrRelation reln, ForkNumber forknum, BlockNumber blkno,
|
||||
/* In case of unlogged build we need to avoid race condition at unlogged build end.
|
||||
* Obtain shared lock here to prevent backend completing unlogged build from performing cleanup amnd remvong files.
|
||||
*/
|
||||
fs_shared_lock();
|
||||
fs_locked = true;
|
||||
LWLockAcquire(finish_unlogged_build_lock, LW_SHARED);
|
||||
is_locked = true;
|
||||
/*
|
||||
* Recheck relkind under lock - may be unlogged build is already finished
|
||||
*/
|
||||
@@ -1734,9 +1734,9 @@ neon_writev(SMgrRelation reln, ForkNumber forknum, BlockNumber blkno,
|
||||
/* It exists locally. Guess it's unlogged then. */
|
||||
mdwritev(reln, forknum, blkno, buffers, nblocks, skipFsync);
|
||||
}
|
||||
if (fs_locked)
|
||||
if (is_locked)
|
||||
{
|
||||
fs_unlock();
|
||||
LWLockRelease(finish_unlogged_build_lock);
|
||||
}
|
||||
if (relkind == RELKIND_UNLOGGED || relkind == RELKIND_UNLOGGED_BUILD)
|
||||
{
|
||||
@@ -2155,9 +2155,9 @@ neon_end_unlogged_build(SMgrRelation reln)
|
||||
MAIN_FORKNUM);
|
||||
|
||||
/* Obtain exclusive lock to prevent concrrent writes to the file while we performing cleanup */
|
||||
fs_exclusive_lock();
|
||||
LWLockAcquire(finish_unlogged_build_lock, LW_EXCLUSIVE);
|
||||
unlogged_build_rel_entry->relkind = RELKIND_PERMANENT;
|
||||
fs_unlock();
|
||||
LWLockRelease(finish_unlogged_build_lock);
|
||||
|
||||
/* Remove local copy */
|
||||
for (int forknum = 0; forknum <= MAX_FORKNUM; forknum++)
|
||||
|
||||
Reference in New Issue
Block a user