isolation-fix.patch
application/octet-stream
Filename: isolation-fix.patch
Type: application/octet-stream
Part: 0
Message:
Re: random isolation test failures
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/test/isolation/isolationtester.c | 32 | 2 |
| src/test/isolation/isolationtester.h | 1 | 0 |
diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c
index 0164012..852ba77 100644
--- a/src/test/isolation/isolationtester.c
+++ b/src/test/isolation/isolationtester.c
@@ -455,10 +455,29 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
else if (try_complete_step(step, STEP_NONBLOCK))
waiting = step;
}
+ for (i = 0; i < nsteps; i++)
+ {
+ Step *step = steps[i];
+
+ if (step->errormsg)
+ {
+ fprintf(stdout, "%s\n", step->errormsg);
+ free(step->errormsg);
+ step->errormsg = NULL;
+ }
+ }
/* Finish any waiting query. */
if (waiting != NULL)
+ {
try_complete_step(waiting, STEP_RETRY);
+ if (waiting->errormsg)
+ {
+ fprintf(stdout, "%s\n", waiting->errormsg);
+ free(waiting->errormsg);
+ waiting->errormsg = NULL;
+ }
+ }
/* Perform per-session teardown */
for (i = 0; i < testspec->nsessions; i++)
@@ -505,6 +524,9 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
* When calling this function on behalf of a given step for a second or later
* time, pass the STEP_RETRY flag. This only affects the messages printed.
*
+ * If the connection returns an error, the message is saved in step->errormsg.
+ * Caller is responsible for reporting it as appropriate.
+ *
* If the STEP_NONBLOCK flag was specified and the query is waiting to acquire
* a lock, returns true. Otherwise, returns false.
*/
@@ -579,9 +601,17 @@ try_complete_step(Step *step, int flags)
printResultSet(res);
break;
case PGRES_FATAL_ERROR:
+ if (step->errormsg != NULL)
+ {
+ printf("WARNING: this step had already emitted an error message\n");
+ printf("%s\n", step->errormsg);
+ }
/* Detail may contain xid values, so just show primary. */
- printf("%s: %s\n", PQresultErrorField(res, PG_DIAG_SEVERITY),
- PQresultErrorField(res, PG_DIAG_MESSAGE_PRIMARY));
+ step->errormsg = malloc(5 + strlen(PQresultErrorField(res, PG_DIAG_SEVERITY)) +
+ strlen(PQresultErrorField(res, PG_DIAG_MESSAGE_PRIMARY)));
+ sprintf(step->errormsg, "%s: %s",
+ PQresultErrorField(res, PG_DIAG_SEVERITY),
+ PQresultErrorField(res, PG_DIAG_MESSAGE_PRIMARY));
break;
default:
printf("unexpected result status: %s\n",
diff --git a/src/test/isolation/isolationtester.h b/src/test/isolation/isolationtester.h
index 377c10c..1e286df 100644
--- a/src/test/isolation/isolationtester.h
+++ b/src/test/isolation/isolationtester.h
@@ -31,6 +31,7 @@ struct Step
int session;
char *name;
char *sql;
+ char *errormsg;
};
typedef struct