pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
notice processors for isolationtester
4+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2018-11-09 a28e10e82e  Indicate session name in isolationtester notices
* notice processors for isolationtester
@ 2018-10-24 21:34  Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Alvaro Herrera @ 2018-10-24 21:34 UTC (permalink / raw)
  To: pgsql-hackers

Recently while testing a patch I found it immensely useful to
distinguish which session each WARNING message came from, when bespoke
tests were run under isolationtester.  Current code does not show that,
so I developed this patch adding notice processors, and then it does.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

isolationtester-notices.patch (text/x-diff, 9.6K) download commit dbbd8840ab070ced5dcd1eefaa67319bd9747b0c Author: Alvaro Herrera <alvherre@alvh.no-ip.org> AuthorDate: Thu Sep 27 16:37:43 2018 -0300 CommitDate: Wed Oct 24 18:31:00 2018 -0300 Have isolationtester prefix WARNING with session name diff --git a/src/test/isolation/expected/vacuum-concurrent-drop.out b/src/test/isolation/expected/vacuum-concurrent-drop.out index bb92e80b92..cf348d7e5d 100644 --- a/src/test/isolation/expected/vacuum-concurrent-drop.out +++ b/src/test/isolation/expected/vacuum-concurrent-drop.out @@ -10,7 +10,7 @@ step drop_and_commit: DROP TABLE part2; COMMIT; -WARNING: skipping vacuum of "part2" --- relation no longer exists +s2: WARNING: skipping vacuum of "part2" --- relation no longer exists step vac_specified: <... completed> starting permutation: lock vac_all_parts drop_and_commit @@ -35,7 +35,7 @@ step drop_and_commit: DROP TABLE part2; COMMIT; -WARNING: skipping analyze of "part2" --- relation no longer exists +s2: WARNING: skipping analyze of "part2" --- relation no longer exists step analyze_specified: <... completed> starting permutation: lock analyze_all_parts drop_and_commit @@ -60,7 +60,7 @@ step drop_and_commit: DROP TABLE part2; COMMIT; -WARNING: skipping vacuum of "part2" --- relation no longer exists +s2: WARNING: skipping vacuum of "part2" --- relation no longer exists step vac_analyze_specified: <... completed> starting permutation: lock vac_analyze_all_parts drop_and_commit diff --git a/src/test/isolation/expected/vacuum-conflict.out b/src/test/isolation/expected/vacuum-conflict.out index 06ac75ef23..ffde537305 100644 --- a/src/test/isolation/expected/vacuum-conflict.out +++ b/src/test/isolation/expected/vacuum-conflict.out @@ -4,7 +4,7 @@ starting permutation: s1_begin s1_lock s2_auth s2_vacuum s1_commit s2_reset step s1_begin: BEGIN; step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE; step s2_auth: SET ROLE regress_vacuum_conflict; -WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it +s2: WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it step s2_vacuum: VACUUM vacuum_tab; step s1_commit: COMMIT; step s2_reset: RESET ROLE; @@ -12,7 +12,7 @@ step s2_reset: RESET ROLE; starting permutation: s1_begin s2_auth s2_vacuum s1_lock s1_commit s2_reset step s1_begin: BEGIN; step s2_auth: SET ROLE regress_vacuum_conflict; -WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it +s2: WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it step s2_vacuum: VACUUM vacuum_tab; step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE; step s1_commit: COMMIT; @@ -22,14 +22,14 @@ starting permutation: s1_begin s2_auth s1_lock s2_vacuum s1_commit s2_reset step s1_begin: BEGIN; step s2_auth: SET ROLE regress_vacuum_conflict; step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE; -WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it +s2: WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it step s2_vacuum: VACUUM vacuum_tab; step s1_commit: COMMIT; step s2_reset: RESET ROLE; starting permutation: s2_auth s2_vacuum s1_begin s1_lock s1_commit s2_reset step s2_auth: SET ROLE regress_vacuum_conflict; -WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it +s2: WARNING: skipping "vacuum_tab" --- only table or database owner can vacuum it step s2_vacuum: VACUUM vacuum_tab; step s1_begin: BEGIN; step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE; @@ -40,7 +40,7 @@ starting permutation: s1_begin s1_lock s2_auth s2_analyze s1_commit s2_reset step s1_begin: BEGIN; step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE; step s2_auth: SET ROLE regress_vacuum_conflict; -WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it +s2: WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it step s2_analyze: ANALYZE vacuum_tab; step s1_commit: COMMIT; step s2_reset: RESET ROLE; @@ -48,7 +48,7 @@ step s2_reset: RESET ROLE; starting permutation: s1_begin s2_auth s2_analyze s1_lock s1_commit s2_reset step s1_begin: BEGIN; step s2_auth: SET ROLE regress_vacuum_conflict; -WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it +s2: WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it step s2_analyze: ANALYZE vacuum_tab; step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE; step s1_commit: COMMIT; @@ -58,14 +58,14 @@ starting permutation: s1_begin s2_auth s1_lock s2_analyze s1_commit s2_reset step s1_begin: BEGIN; step s2_auth: SET ROLE regress_vacuum_conflict; step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE; -WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it +s2: WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it step s2_analyze: ANALYZE vacuum_tab; step s1_commit: COMMIT; step s2_reset: RESET ROLE; starting permutation: s2_auth s2_analyze s1_begin s1_lock s1_commit s2_reset step s2_auth: SET ROLE regress_vacuum_conflict; -WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it +s2: WARNING: skipping "vacuum_tab" --- only table or database owner can analyze it step s2_analyze: ANALYZE vacuum_tab; step s1_begin: BEGIN; step s1_lock: LOCK vacuum_tab IN SHARE UPDATE EXCLUSIVE MODE; diff --git a/src/test/isolation/expected/vacuum-skip-locked.out b/src/test/isolation/expected/vacuum-skip-locked.out index 95ca4569cc..99db281a15 100644 --- a/src/test/isolation/expected/vacuum-skip-locked.out +++ b/src/test/isolation/expected/vacuum-skip-locked.out @@ -5,7 +5,7 @@ step lock_share: BEGIN; LOCK part1 IN SHARE MODE; -WARNING: skipping vacuum of "part1" --- lock not available +s2: WARNING: skipping vacuum of "part1" --- lock not available step vac_specified: VACUUM (SKIP_LOCKED) part1, part2; step commit: COMMIT; @@ -26,7 +26,7 @@ step lock_share: BEGIN; LOCK part1 IN SHARE MODE; -WARNING: skipping analyze of "part1" --- lock not available +s2: WARNING: skipping analyze of "part1" --- lock not available step analyze_specified: ANALYZE (SKIP_LOCKED) part1, part2; step commit: COMMIT; @@ -47,7 +47,7 @@ step lock_share: BEGIN; LOCK part1 IN SHARE MODE; -WARNING: skipping vacuum of "part1" --- lock not available +s2: WARNING: skipping vacuum of "part1" --- lock not available step vac_analyze_specified: VACUUM (ANALYZE, SKIP_LOCKED) part1, part2; step commit: COMMIT; @@ -68,7 +68,7 @@ step lock_share: BEGIN; LOCK part1 IN SHARE MODE; -WARNING: skipping vacuum of "part1" --- lock not available +s2: WARNING: skipping vacuum of "part1" --- lock not available step vac_full_specified: VACUUM (SKIP_LOCKED, FULL) part1, part2; step commit: COMMIT; @@ -89,7 +89,7 @@ step lock_access_exclusive: BEGIN; LOCK part1 IN ACCESS EXCLUSIVE MODE; -WARNING: skipping vacuum of "part1" --- lock not available +s2: WARNING: skipping vacuum of "part1" --- lock not available step vac_specified: VACUUM (SKIP_LOCKED) part1, part2; step commit: COMMIT; @@ -110,7 +110,7 @@ step lock_access_exclusive: BEGIN; LOCK part1 IN ACCESS EXCLUSIVE MODE; -WARNING: skipping analyze of "part1" --- lock not available +s2: WARNING: skipping analyze of "part1" --- lock not available step analyze_specified: ANALYZE (SKIP_LOCKED) part1, part2; step commit: COMMIT; @@ -132,7 +132,7 @@ step lock_access_exclusive: BEGIN; LOCK part1 IN ACCESS EXCLUSIVE MODE; -WARNING: skipping vacuum of "part1" --- lock not available +s2: WARNING: skipping vacuum of "part1" --- lock not available step vac_analyze_specified: VACUUM (ANALYZE, SKIP_LOCKED) part1, part2; step commit: COMMIT; @@ -154,7 +154,7 @@ step lock_access_exclusive: BEGIN; LOCK part1 IN ACCESS EXCLUSIVE MODE; -WARNING: skipping vacuum of "part1" --- lock not available +s2: WARNING: skipping vacuum of "part1" --- lock not available step vac_full_specified: VACUUM (SKIP_LOCKED, FULL) part1, part2; step commit: COMMIT; diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c index 62097ab961..e2638553f6 100644 --- a/src/test/isolation/isolationtester.c +++ b/src/test/isolation/isolationtester.c @@ -48,6 +48,8 @@ static int step_qsort_cmp(const void *a, const void *b); static int step_bsearch_cmp(const void *a, const void *b); static void printResultSet(PGresult *res); +static void isotesterNoticeProcessor(void *arg, const char *message); +static void blackholeNoticeProcessor(void *arg, const char *message); /* close all connections and exit */ static void @@ -172,6 +174,21 @@ main(int argc, char **argv) } /* + * Set up notice processors for the user-defined connections, so that + * messages can get printed prefixed with the session names. The + * control connection gets a "blackhole" processor instead (hides all + * messages). + */ + if (i != 0) + PQsetNoticeProcessor(conns[i], + isotesterNoticeProcessor, + (void *) (testspec->sessions[i - 1]->name)); + else + PQsetNoticeProcessor(conns[i], + blackholeNoticeProcessor, + NULL); + + /* * Suppress NOTIFY messages, which otherwise pop into results at odd * places. */ @@ -881,3 +898,17 @@ printResultSet(PGresult *res) printf("\n"); } } + +/* notice processor, prefixes each message with the session name */ +static void +isotesterNoticeProcessor(void *arg, const char *message) +{ + fprintf(stderr, "%s: %s", (char *) arg, message); +} + +/* notice processor, hides the message */ +static void +blackholeNoticeProcessor(void *arg, const char *message) +{ + /* do nothing */ +}
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: notice processors for isolationtester
@ 2018-10-24 21:38  Andres Freund <andres@anarazel.de>
  parent: Alvaro Herrera <alvherre@2ndquadrant.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Andres Freund @ 2018-10-24 21:38 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-hackers

On 2018-10-24 18:34:51 -0300, Alvaro Herrera wrote:
> Recently while testing a patch I found it immensely useful to
> distinguish which session each WARNING message came from, when bespoke
> tests were run under isolationtester.  Current code does not show that,
> so I developed this patch adding notice processors, and then it does.

Neat!




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: notice processors for isolationtester
@ 2018-11-09 04:17  Haribabu Kommi <kommi.haribabu@gmail.com>
  parent: Alvaro Herrera <alvherre@2ndquadrant.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Haribabu Kommi @ 2018-11-09 04:17 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-hackers

On Thu, Oct 25, 2018 at 8:35 AM Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:

> Recently while testing a patch I found it immensely useful to
> distinguish which session each WARNING message came from, when bespoke
> tests were run under isolationtester.  Current code does not show that,
> so I developed this patch adding notice processors, and then it does.
>

I reviewed and tested the patch. It is working as expected.
Providing session name helps in debugging.

Marking the patch as ready for committer.

Regards,
Haribabu Kommi
Fujitsu Australia

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: notice processors for isolationtester
@ 2018-11-09 16:16  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Haribabu Kommi <kommi.haribabu@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Alvaro Herrera @ 2018-11-09 16:16 UTC (permalink / raw)
  To: Haribabu Kommi <kommi.haribabu@gmail.com>; +Cc: pgsql-hackers

On 2018-Nov-09, Haribabu Kommi wrote:

> On Thu, Oct 25, 2018 at 8:35 AM Alvaro Herrera <alvherre@2ndquadrant.com>
> wrote:
> 
> > Recently while testing a patch I found it immensely useful to
> > distinguish which session each WARNING message came from, when bespoke
> > tests were run under isolationtester.  Current code does not show that,
> > so I developed this patch adding notice processors, and then it does.
> 
> I reviewed and tested the patch. It is working as expected.
> Providing session name helps in debugging.
> 
> Marking the patch as ready for committer.

Thanks!  Pushed.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2018-11-09 16:16 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-24 21:34 notice processors for isolationtester Alvaro Herrera <alvherre@2ndquadrant.com>
2018-10-24 21:38 ` Andres Freund <andres@anarazel.de>
2018-11-09 04:17 ` Haribabu Kommi <kommi.haribabu@gmail.com>
2018-11-09 16:16   ` Alvaro Herrera <alvherre@2ndquadrant.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox