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

Commit7064fd0

Browse files
committed
Detect invalid permutations in isolationtester
isolationtester is now able to continue running other permutations whenit detects that one of them is invalid, which is useful during initialdevelopment of spec files.Author: Alexander Shulgin
1 parentd2a7583 commit7064fd0

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

‎src/test/isolation/isolationtester.c

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,53 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
550550
for (i=0;i<nsteps;i++)
551551
{
552552
Step*step=steps[i];
553+
PGconn*conn=conns[1+step->session];
553554

554-
if (!PQsendQuery(conns[1+step->session],step->sql))
555+
if (waiting!=NULL&&step->session==waiting->session)
556+
{
557+
PGcancel*cancel;
558+
PGresult*res;
559+
intj;
560+
561+
/*
562+
* This permutation is invalid: it can never happen in real life.
563+
*
564+
* A session is blocked on an earlier step (waiting) and no further
565+
* steps from this session can run until it is unblocked, but it
566+
* can only be unblocked by running steps from other sessions.
567+
*/
568+
fprintf(stderr,"invalid permutation detected\n");
569+
570+
/* Cancel the waiting statement from this session. */
571+
cancel=PQgetCancel(conn);
572+
if (cancel!=NULL)
573+
{
574+
charbuf[256];
575+
576+
PQcancel(cancel,buf,sizeof(buf));
577+
578+
/* Be sure to consume the error message. */
579+
while ((res=PQgetResult(conn))!=NULL)
580+
PQclear(res);
581+
582+
PQfreeCancel(cancel);
583+
}
584+
585+
/*
586+
* Now we really have to complete all the running transactions to
587+
* make sure teardown doesn't block.
588+
*/
589+
for (j=1;j<nconns;j++)
590+
{
591+
res=PQexec(conns[j],"ROLLBACK");
592+
if (res!=NULL)
593+
PQclear(res);
594+
}
595+
596+
gototeardown;
597+
}
598+
599+
if (!PQsendQuery(conn,step->sql))
555600
{
556601
fprintf(stdout,"failed to send query for step %s: %s\n",
557602
step->name,PQerrorMessage(conns[1+step->session]));
@@ -590,6 +635,7 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
590635
report_error_message(waiting);
591636
}
592637

638+
teardown:
593639
/* Perform per-session teardown */
594640
for (i=0;i<testspec->nsessions;i++)
595641
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp