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

Commitb578404

Browse files
committed
Sync isolationtester's handling of notice/warning messages with HEAD.
Back-patch relevant parts of these commits:3071763 Fix isolationtester race condition for notices sent before blockingebd4992 Don't drop NOTICE messages in isolation testsa28e10e Indicate session name in isolationtester noticesThis ensures that older versions of the isolationtester will handleNOTICE/WARNING messages the same way as HEAD and v12 do. While thisisn't fixing any critical problem right now, it seems like a prudentchange to prevent surprises (like we had yesterday...) withback-patches of future isolation test changes.Back-patch as far as 9.6. Due to the significant changes we made inisolationtester in 9.6, back-patching isolation tests further thanthat is going to be risky anyway; besides, this patch doesn't applycleanly before that.Discussion:https://postgr.es/m/E1i7IqC-0000Uc-5H@gemulon.postgresql.org
1 parent8459f90 commitb578404

File tree

5 files changed

+106
-22
lines changed

5 files changed

+106
-22
lines changed

‎src/test/isolation/expected/insert-conflict-specconflict.out

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ pg_advisory_locksess lock
1313
step controller_show: SELECT * FROM upserttest;
1414
key data
1515

16+
s1: NOTICE: called for k1
17+
s1: NOTICE: blocking 3
1618
step s1_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s1') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s1'; <waiting ...>
19+
s2: NOTICE: called for k1
20+
s2: NOTICE: blocking 3
1721
step s2_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s2') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s2'; <waiting ...>
1822
step controller_show: SELECT * FROM upserttest;
1923
key data
@@ -30,10 +34,14 @@ step controller_unlock_1_3: SELECT pg_advisory_unlock(1, 3);
3034
pg_advisory_unlock
3135

3236
t
37+
s1: NOTICE: called for k1
38+
s1: NOTICE: blocking 2
3339
step controller_unlock_2_3: SELECT pg_advisory_unlock(2, 3);
3440
pg_advisory_unlock
3541

3642
t
43+
s2: NOTICE: called for k1
44+
s2: NOTICE: blocking 2
3745
step controller_show: SELECT * FROM upserttest;
3846
key data
3947

@@ -50,6 +58,10 @@ step controller_unlock_1_2: SELECT pg_advisory_unlock(1, 2);
5058
pg_advisory_unlock
5159

5260
t
61+
s1: NOTICE: called for k1
62+
s1: NOTICE: blocking 2
63+
s1: NOTICE: called for k1
64+
s1: NOTICE: blocking 2
5365
step s1_upsert: <... completed>
5466
step controller_show: SELECT * FROM upserttest;
5567
key data
@@ -69,7 +81,11 @@ pg_advisory_locksess lock
6981
step controller_show: SELECT * FROM upserttest;
7082
key data
7183

84+
s1: NOTICE: called for k1
85+
s1: NOTICE: blocking 3
7286
step s1_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s1') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s1'; <waiting ...>
87+
s2: NOTICE: called for k1
88+
s2: NOTICE: blocking 3
7389
step s2_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s2') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s2'; <waiting ...>
7490
step controller_show: SELECT * FROM upserttest;
7591
key data
@@ -86,10 +102,14 @@ step controller_unlock_1_3: SELECT pg_advisory_unlock(1, 3);
86102
pg_advisory_unlock
87103

88104
t
105+
s1: NOTICE: called for k1
106+
s1: NOTICE: blocking 2
89107
step controller_unlock_2_3: SELECT pg_advisory_unlock(2, 3);
90108
pg_advisory_unlock
91109

92110
t
111+
s2: NOTICE: called for k1
112+
s2: NOTICE: blocking 2
93113
step controller_show: SELECT * FROM upserttest;
94114
key data
95115

@@ -106,6 +126,10 @@ step controller_unlock_2_2: SELECT pg_advisory_unlock(2, 2);
106126
pg_advisory_unlock
107127

108128
t
129+
s2: NOTICE: called for k1
130+
s2: NOTICE: blocking 2
131+
s2: NOTICE: called for k1
132+
s2: NOTICE: blocking 2
109133
step s2_upsert: <... completed>
110134
step controller_show: SELECT * FROM upserttest;
111135
key data
@@ -127,7 +151,11 @@ key data
127151

128152
step s1_begin: BEGIN;
129153
step s2_begin: BEGIN;
154+
s1: NOTICE: called for k1
155+
s1: NOTICE: blocking 3
130156
step s1_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s1') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s1'; <waiting ...>
157+
s2: NOTICE: called for k1
158+
s2: NOTICE: blocking 3
131159
step s2_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s2') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s2'; <waiting ...>
132160
step controller_show: SELECT * FROM upserttest;
133161
key data
@@ -144,10 +172,14 @@ step controller_unlock_1_3: SELECT pg_advisory_unlock(1, 3);
144172
pg_advisory_unlock
145173

146174
t
175+
s1: NOTICE: called for k1
176+
s1: NOTICE: blocking 2
147177
step controller_unlock_2_3: SELECT pg_advisory_unlock(2, 3);
148178
pg_advisory_unlock
149179

150180
t
181+
s2: NOTICE: called for k1
182+
s2: NOTICE: blocking 2
151183
step controller_show: SELECT * FROM upserttest;
152184
key data
153185

@@ -163,10 +195,16 @@ step controller_unlock_2_2: SELECT pg_advisory_unlock(2, 2);
163195
pg_advisory_unlock
164196

165197
t
198+
s2: NOTICE: called for k1
199+
s2: NOTICE: blocking 2
200+
s2: NOTICE: called for k1
201+
s2: NOTICE: blocking 2
166202
step controller_show: SELECT * FROM upserttest;
167203
key data
168204

169205
step s1_commit: COMMIT;
206+
s2: NOTICE: called for k1
207+
s2: NOTICE: blocking 2
170208
step s2_upsert: <... completed>
171209
step controller_show: SELECT * FROM upserttest;
172210
key data

‎src/test/isolation/expected/plpgsql-toast.out

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ do $$
2222
delete from test1;
2323
commit;
2424
perform pg_advisory_lock(1);
25-
raise notice 'x = %',x;
25+
raise notice 'length(x) = %',length(x);
2626
end;
2727
$$;
2828
<waiting ...>
@@ -35,6 +35,7 @@ step unlock:
3535
pg_advisory_unlock
3636

3737
t
38+
s1: NOTICE: length(x) = 6000
3839
step assign1: <... completed>
3940

4041
starting permutation: lock assign2 vacuum unlock
@@ -59,7 +60,7 @@ do $$
5960
delete from test1;
6061
commit;
6162
perform pg_advisory_lock(1);
62-
raise notice 'x = %',x;
63+
raise notice 'length(x) = %',length(x);
6364
end;
6465
$$;
6566
<waiting ...>
@@ -72,6 +73,7 @@ step unlock:
7273
pg_advisory_unlock
7374

7475
t
76+
s1: NOTICE: length(x) = 6000
7577
step assign2: <... completed>
7678

7779
starting permutation: lock assign3 vacuum unlock
@@ -97,7 +99,7 @@ do $$
9799
delete from test1;
98100
commit;
99101
perform pg_advisory_lock(1);
100-
raise notice 'r = %',r;
102+
raise notice 'length(r) = %',length(r::text);
101103
end;
102104
$$;
103105
<waiting ...>
@@ -110,6 +112,7 @@ step unlock:
110112
pg_advisory_unlock
111113

112114
t
115+
s1: NOTICE: length(r) = 6004
113116
step assign3: <... completed>
114117

115118
starting permutation: lock assign4 vacuum unlock
@@ -134,7 +137,7 @@ do $$
134137
delete from test1;
135138
commit;
136139
perform pg_advisory_lock(1);
137-
raise notice 'r = %',r;
140+
raise notice 'length(r) = %',length(r::text);
138141
end;
139142
$$;
140143
<waiting ...>
@@ -147,6 +150,7 @@ step unlock:
147150
pg_advisory_unlock
148151

149152
t
153+
s1: NOTICE: length(r) = 6004
150154
step assign4: <... completed>
151155

152156
starting permutation: lock assign5 vacuum unlock
@@ -173,7 +177,7 @@ do $$
173177
delete from test1;
174178
commit;
175179
perform pg_advisory_lock(1);
176-
raise notice 'r = %',r;
180+
raise notice 'length(r) = %',length(r::text);
177181
end;
178182
$$;
179183
<waiting ...>
@@ -186,4 +190,5 @@ step unlock:
186190
pg_advisory_unlock
187191

188192
t
193+
s1: NOTICE: length(r) = 6002
189194
step assign5: <... completed>

‎src/test/isolation/expected/vacuum-concurrent-drop.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ step drop_and_commit:
1010
DROP TABLE part2;
1111
COMMIT;
1212

13-
WARNING: skipping vacuum of "part2" --- relation no longer exists
13+
s2:WARNING: skipping vacuum of "part2" --- relation no longer exists
1414
step vac_specified: <... completed>
1515

1616
starting permutation: lock vac_all_parts drop_and_commit
@@ -35,7 +35,7 @@ step drop_and_commit:
3535
DROP TABLE part2;
3636
COMMIT;
3737

38-
WARNING: skipping analyze of "part2" --- relation no longer exists
38+
s2:WARNING: skipping analyze of "part2" --- relation no longer exists
3939
step analyze_specified: <... completed>
4040

4141
starting permutation: lock analyze_all_parts drop_and_commit
@@ -60,7 +60,7 @@ step drop_and_commit:
6060
DROP TABLE part2;
6161
COMMIT;
6262

63-
WARNING: skipping vacuum of "part2" --- relation no longer exists
63+
s2:WARNING: skipping vacuum of "part2" --- relation no longer exists
6464
step vac_analyze_specified: <... completed>
6565

6666
starting permutation: lock vac_analyze_all_parts drop_and_commit

‎src/test/isolation/isolationtester.c

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ static intstep_qsort_cmp(const void *a, const void *b);
4848
staticintstep_bsearch_cmp(constvoid*a,constvoid*b);
4949

5050
staticvoidprintResultSet(PGresult*res);
51+
staticvoidisotesterNoticeProcessor(void*arg,constchar*message);
52+
staticvoidblackholeNoticeProcessor(void*arg,constchar*message);
5153

5254
/* close all connections and exit */
5355
staticvoid
@@ -172,16 +174,19 @@ main(int argc, char **argv)
172174
}
173175

174176
/*
175-
* Suppress NOTIFY messages, which otherwise pop into results at odd
176-
* places.
177+
* Set up notice processors for the user-defined connections, so that
178+
* messages can get printed prefixed with the session names. The
179+
* control connection gets a "blackhole" processor instead (hides all
180+
* messages).
177181
*/
178-
res=PQexec(conns[i],"SET client_min_messages = warning;");
179-
if (PQresultStatus(res)!=PGRES_COMMAND_OK)
180-
{
181-
fprintf(stderr,"message level setup failed: %s",PQerrorMessage(conns[i]));
182-
exit_nicely();
183-
}
184-
PQclear(res);
182+
if (i!=0)
183+
PQsetNoticeProcessor(conns[i],
184+
isotesterNoticeProcessor,
185+
(void*) (testspec->sessions[i-1]->name));
186+
else
187+
PQsetNoticeProcessor(conns[i],
188+
blackholeNoticeProcessor,
189+
NULL);
185190

186191
/* Get the backend pid for lock wait checking. */
187192
res=PQexec(conns[i],"SELECT pg_backend_pid()");
@@ -751,6 +756,28 @@ try_complete_step(Step *step, int flags)
751756

752757
if (waiting)/* waiting to acquire a lock */
753758
{
759+
/*
760+
* Since it takes time to perform the lock-check query,
761+
* some data --- notably, NOTICE messages --- might have
762+
* arrived since we looked. We must call PQconsumeInput
763+
* and then PQisBusy to collect and process any such
764+
* messages. In the (unlikely) case that PQisBusy then
765+
* returns false, we might as well go examine the
766+
* available result.
767+
*/
768+
if (!PQconsumeInput(conn))
769+
{
770+
fprintf(stderr,"PQconsumeInput failed: %s\n",
771+
PQerrorMessage(conn));
772+
exit(1);
773+
}
774+
if (!PQisBusy(conn))
775+
break;
776+
777+
/*
778+
* conn is still busy, so conclude that the step really is
779+
* waiting.
780+
*/
754781
if (!(flags&STEP_RETRY))
755782
printf("step %s: %s <waiting ...>\n",
756783
step->name,step->sql);
@@ -881,3 +908,17 @@ printResultSet(PGresult *res)
881908
printf("\n");
882909
}
883910
}
911+
912+
/* notice processor, prefixes each message with the session name */
913+
staticvoid
914+
isotesterNoticeProcessor(void*arg,constchar*message)
915+
{
916+
printf("%s: %s", (char*)arg,message);
917+
}
918+
919+
/* notice processor, hides the message */
920+
staticvoid
921+
blackholeNoticeProcessor(void*arg,constchar*message)
922+
{
923+
/* do nothing */
924+
}

‎src/test/isolation/specs/plpgsql-toast.spec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ do $$
4040
deletefromtest1;
4141
commit;
4242
performpg_advisory_lock(1);
43-
raisenotice'x = %',x;
43+
raisenotice'length(x) = %',length(x);
4444
end;
4545
$$;
4646
}
@@ -56,7 +56,7 @@ do $$
5656
deletefromtest1;
5757
commit;
5858
performpg_advisory_lock(1);
59-
raisenotice'x = %',x;
59+
raisenotice'length(x) = %',length(x);
6060
end;
6161
$$;
6262
}
@@ -73,7 +73,7 @@ do $$
7373
deletefromtest1;
7474
commit;
7575
performpg_advisory_lock(1);
76-
raisenotice'r = %',r;
76+
raisenotice'length(r) = %',length(r::text);
7777
end;
7878
$$;
7979
}
@@ -89,7 +89,7 @@ do $$
8989
deletefromtest1;
9090
commit;
9191
performpg_advisory_lock(1);
92-
raisenotice'r = %',r;
92+
raisenotice'length(r) = %',length(r::text);
9393
end;
9494
$$;
9595
}
@@ -107,7 +107,7 @@ do $$
107107
deletefromtest1;
108108
commit;
109109
performpg_advisory_lock(1);
110-
raisenotice'r = %',r;
110+
raisenotice'length(r) = %',length(r::text);
111111
end;
112112
$$;
113113
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp