Skip to content

Commit 174bbc5

Browse files
committed
pathman: concurrent config initialization issue fixed
1 parent 657ac2b commit 174bbc5

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

contrib/pg_pathman/dsm_array.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ init_dsm_segment(size_t blocks_count, size_t block_size)
7979
{
8080
bool ret;
8181

82-
/* lock here */
83-
LWLockAcquire(pmstate->dsm_init_lock, LW_EXCLUSIVE);
84-
8582
/* if there is already an existing segment then attach to it */
8683
if (dsm_cfg->segment_handle != 0)
8784
{
@@ -110,8 +107,6 @@ init_dsm_segment(size_t blocks_count, size_t block_size)
110107
* destroyed by the end of transaction
111108
*/
112109
dsm_pin_mapping(segment);
113-
/* unlock here */
114-
LWLockRelease(pmstate->dsm_init_lock);
115110

116111
return ret;
117112
}

contrib/pg_pathman/init.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ load_config(void)
7878
Oid *databases;
7979

8080
initialization_needed = false;
81+
82+
LWLockAcquire(pmstate->dsm_init_lock, LW_EXCLUSIVE);
8183
new_segment_created = init_dsm_segment(INITIAL_BLOCKS_COUNT, 32);
8284

8385
/* If dsm segment just created */
@@ -88,29 +90,22 @@ load_config(void)
8890
* oid into it. This array contains databases oids
8991
* that have already been cached (to prevent repeat caching)
9092
*/
91-
LWLockAcquire(pmstate->dsm_init_lock, LW_EXCLUSIVE);
92-
9393
if (&pmstate->databases.length > 0)
9494
free_dsm_array(&pmstate->databases);
9595
alloc_dsm_array(&pmstate->databases, sizeof(Oid), 1);
9696
databases = (Oid *) dsm_array_get_pointer(&pmstate->databases);
9797
databases[0] = MyDatabaseId;
98-
99-
LWLockRelease(pmstate->dsm_init_lock);
10098
}
10199
else
102100
{
103101
int databases_count = pmstate->databases.length;
104102
int i;
105103

106104
/* Check if we already cached config for current database */
107-
LWLockAcquire(pmstate->dsm_init_lock, LW_EXCLUSIVE);
108-
109105
databases = (Oid *) dsm_array_get_pointer(&pmstate->databases);
110106
for(i=0; i<databases_count; i++)
111107
if (databases[i] == MyDatabaseId)
112108
{
113-
// LWLockRelease(pmstate->load_config_lock);
114109
LWLockRelease(pmstate->dsm_init_lock);
115110
return;
116111
}
@@ -119,14 +114,13 @@ load_config(void)
119114
resize_dsm_array(&pmstate->databases, sizeof(Oid), databases_count + 1);
120115
databases = (Oid *) dsm_array_get_pointer(&pmstate->databases);
121116
databases[databases_count] = MyDatabaseId;
122-
123-
LWLockRelease(pmstate->dsm_init_lock);
124117
}
125118

126119
/* Load cache */
127120
LWLockAcquire(pmstate->load_config_lock, LW_EXCLUSIVE);
128121
load_relations_hashtable(new_segment_created);
129122
LWLockRelease(pmstate->load_config_lock);
123+
LWLockRelease(pmstate->dsm_init_lock);
130124
}
131125

132126
/*

0 commit comments

Comments
 (0)