Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit554f66b

Browse files
committed
pathman: windows issues
1 parent885c868 commit554f66b

File tree

5 files changed

+60
-29
lines changed

5 files changed

+60
-29
lines changed

‎contrib/pg_pathman/dsm_array.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ init_dsm_segment(size_t blocks_count, size_t block_size)
6969
boolret;
7070

7171
/* lock here */
72-
LWLockAcquire(dsm_init_lock,LW_EXCLUSIVE);
72+
LWLockAcquire(pmstate->load_config_lock,LW_EXCLUSIVE);
7373

7474
/* if there is already an existing segment then attach to it */
7575
if (dsm_cfg->segment_handle!=0)
@@ -99,9 +99,8 @@ init_dsm_segment(size_t blocks_count, size_t block_size)
9999
* destroyed by the end of transaction
100100
*/
101101
dsm_pin_mapping(segment);
102-
103102
/* unlock here */
104-
LWLockRelease(dsm_init_lock);
103+
LWLockRelease(pmstate->load_config_lock);
105104

106105
returnret;
107106
}

‎contrib/pg_pathman/init.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include"utils/bytea.h"
1414
#include"utils/snapmgr.h"
1515

16+
#include"miscadmin.h"
17+
1618

1719
HTAB*relations=NULL;
1820
HTAB*range_restrictions=NULL;
@@ -28,6 +30,31 @@ static int cmp_range_entries(const void *p1, const void *p2);
2830
void
2931
init_shmem_config()
3032
{
33+
boolfound;
34+
35+
/* Check if module was initialized in postmaster */
36+
pmstate=ShmemInitStruct("pathman state",sizeof(PathmanState),&found);
37+
if (!found)
38+
{
39+
/*
40+
* Initialize locks in postmaster
41+
*/
42+
if (!IsUnderPostmaster)
43+
{
44+
/* Initialize locks */
45+
pmstate->load_config_lock=LWLockAssign();
46+
pmstate->dsm_init_lock=LWLockAssign();
47+
pmstate->edit_partitions_lock=LWLockAssign();
48+
}
49+
else
50+
{
51+
elog(ERROR,"Pathman module must be initialized in postmaster. "
52+
"Put the following line to configuration file: "
53+
"shared_preload_libraries='pg_pathman'");
54+
initialization_needed= false;
55+
}
56+
}
57+
3158
create_relations_hashtable();
3259
create_range_restrictions_hashtable();
3360
}
@@ -46,9 +73,9 @@ load_config(void)
4673
/* if config is not loaded */
4774
if (new_segment_created)
4875
{
49-
LWLockAcquire(load_config_lock,LW_EXCLUSIVE);
76+
LWLockAcquire(pmstate->load_config_lock,LW_EXCLUSIVE);
5077
load_relations_hashtable(new_segment_created);
51-
LWLockRelease(load_config_lock);
78+
LWLockRelease(pmstate->load_config_lock);
5279
}
5380
}
5481

‎contrib/pg_pathman/pathman.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ typedef struct RangeRelation
9898
DsmArrayranges;
9999
}RangeRelation;
100100

101+
typedefstructPathmanState
102+
{
103+
LWLock*load_config_lock;
104+
LWLock*dsm_init_lock;
105+
LWLock*edit_partitions_lock;
106+
}PathmanState;
107+
101108
#definePATHMAN_GET_DATUM(value,by_val) ( (by_val) ? (value) : PointerGetDatum(&value) )
102109

103110
typedefintIndexRange;
@@ -133,10 +140,10 @@ int irange_list_length(List *rangeset);
133140
boolirange_list_find(List*rangeset,intindex,bool*lossy);
134141

135142

136-
LWLock*load_config_lock;
137-
LWLock*dsm_init_lock;
138-
LWLock*edit_partitions_lock;
139-
143+
//LWLock *load_config_lock;
144+
//LWLock *dsm_init_lock;
145+
//LWLock *edit_partitions_lock;
146+
PathmanState*pmstate;
140147

141148
/* Dynamic shared memory functions */
142149
voidinit_dsm_config(void);

‎contrib/pg_pathman/pg_pathman.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,16 @@ static void set_pathkeys(PlannerInfo *root, RelOptInfo *childrel, Path *path);
103103
void
104104
_PG_init(void)
105105
{
106+
/*
107+
elog(WARNING, "Pathman initialization. IsUnderPostmaster: %d", IsUnderPostmaster);
106108
if (IsUnderPostmaster)
107109
{
108110
elog(ERROR, "Pathman module must be initialized in postmaster. "
109111
"Put the following line to configuration file: "
110112
"shared_preload_libraries='pg_pathman'");
111113
initialization_needed = false;
112114
}
115+
*/
113116

114117
set_rel_pathlist_hook_original=set_rel_pathlist_hook;
115118
set_rel_pathlist_hook=pathman_set_rel_pathlist_hook;
@@ -246,16 +249,11 @@ pathman_shmem_startup(void)
246249
{
247250
/* Initialize locks */
248251
RequestAddinLWLocks(3);
249-
load_config_lock=LWLockAssign();
250-
dsm_init_lock=LWLockAssign();
251-
edit_partitions_lock=LWLockAssign();
252-
253-
LWLockAcquire(AddinShmemInitLock,LW_EXCLUSIVE);
254252

255253
/* Allocate shared memory objects */
254+
LWLockAcquire(AddinShmemInitLock,LW_EXCLUSIVE);
256255
init_dsm_config();
257256
init_shmem_config();
258-
259257
LWLockRelease(AddinShmemInitLock);
260258

261259
/* Invoke original hook if needed */

‎contrib/pg_pathman/pl_funcs.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ PG_FUNCTION_INFO_V1( get_max_range_value );
2929
Datum
3030
on_partitions_created(PG_FUNCTION_ARGS)
3131
{
32-
LWLockAcquire(load_config_lock,LW_EXCLUSIVE);
32+
LWLockAcquire(pmstate->load_config_lock,LW_EXCLUSIVE);
3333

3434
/* Reload config */
3535
/* TODO: reload just the specified relation */
3636
load_relations_hashtable(false);
3737

38-
LWLockRelease(load_config_lock);
38+
LWLockRelease(pmstate->load_config_lock);
3939

4040
PG_RETURN_NULL();
4141
}
@@ -51,10 +51,10 @@ on_partitions_updated(PG_FUNCTION_ARGS)
5151
prel=get_pathman_relation_info(relid,NULL);
5252
if (prel!=NULL)
5353
{
54-
LWLockAcquire(load_config_lock,LW_EXCLUSIVE);
54+
LWLockAcquire(pmstate->load_config_lock,LW_EXCLUSIVE);
5555
remove_relation_info(relid);
5656
load_relations_hashtable(false);
57-
LWLockRelease(load_config_lock);
57+
LWLockRelease(pmstate->load_config_lock);
5858
}
5959

6060
PG_RETURN_NULL();
@@ -65,13 +65,13 @@ on_partitions_removed(PG_FUNCTION_ARGS)
6565
{
6666
Oidrelid;
6767

68-
LWLockAcquire(load_config_lock,LW_EXCLUSIVE);
68+
LWLockAcquire(pmstate->load_config_lock,LW_EXCLUSIVE);
6969

7070
/* parent relation oid */
7171
relid=DatumGetInt32(PG_GETARG_DATUM(0));
7272
remove_relation_info(relid);
7373

74-
LWLockRelease(load_config_lock);
74+
LWLockRelease(pmstate->load_config_lock);
7575

7676
PG_RETURN_NULL();
7777
}
@@ -129,10 +129,10 @@ find_or_create_range_partition(PG_FUNCTION_ARGS)
129129
Oidchild_oid;
130130

131131
/* Lock config before appending new partitions */
132-
LWLockAcquire(load_config_lock,LW_EXCLUSIVE);
132+
LWLockAcquire(pmstate->load_config_lock,LW_EXCLUSIVE);
133133

134134
/* Restrict concurrent partition creation */
135-
LWLockAcquire(edit_partitions_lock,LW_EXCLUSIVE);
135+
LWLockAcquire(pmstate->edit_partitions_lock,LW_EXCLUSIVE);
136136

137137
/*
138138
* Check if someone else has already created partition.
@@ -141,8 +141,8 @@ find_or_create_range_partition(PG_FUNCTION_ARGS)
141141
pos=range_binary_search(rangerel,&cmp_func,value,&found);
142142
if (found)
143143
{
144-
LWLockRelease(edit_partitions_lock);
145-
LWLockRelease(load_config_lock);
144+
LWLockRelease(pmstate->edit_partitions_lock);
145+
LWLockRelease(pmstate->load_config_lock);
146146
PG_RETURN_OID(ranges[pos].child_oid);
147147
}
148148

@@ -155,8 +155,8 @@ find_or_create_range_partition(PG_FUNCTION_ARGS)
155155
// elog(WARNING, "Worker finished");
156156

157157
/* Release locks */
158-
LWLockRelease(edit_partitions_lock);
159-
LWLockRelease(load_config_lock);
158+
LWLockRelease(pmstate->edit_partitions_lock);
159+
LWLockRelease(pmstate->load_config_lock);
160160

161161
/* Repeat binary search */
162162
ranges=dsm_array_get_pointer(&rangerel->ranges);
@@ -363,7 +363,7 @@ acquire_partitions_lock(PG_FUNCTION_ARGS)
363363
{
364364
// int relid = DatumGetInt32(PG_GETARG_DATUM(0));
365365
// LockRelationOid(relid, AccessExclusiveLock);
366-
LWLockAcquire(edit_partitions_lock,LW_EXCLUSIVE);
366+
LWLockAcquire(pmstate->edit_partitions_lock,LW_EXCLUSIVE);
367367
PG_RETURN_NULL();
368368
}
369369

@@ -372,6 +372,6 @@ release_partitions_lock(PG_FUNCTION_ARGS)
372372
{
373373
// int relid = DatumGetInt32(PG_GETARG_DATUM(0));
374374
// UnlockRelationOid(relid, AccessExclusiveLock);
375-
LWLockRelease(edit_partitions_lock);
375+
LWLockRelease(pmstate->edit_partitions_lock);
376376
PG_RETURN_NULL();
377377
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp