step s1u: UPDATE parent SET aux = 'bar'; <waiting ...>
step s2u: UPDATE parent SET aux = 'baz';
step s1u: <... completed>
-ERROR: deadlock detected
+error in steps s2u s1u: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s2i: INSERT INTO child VALUES (2, 1);
step s2u: UPDATE parent SET aux = 'baz'; <waiting ...>
step s1u: UPDATE parent SET aux = 'bar';
-ERROR: deadlock detected
step s2u: <... completed>
+error in steps s1u s2u: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
step s1u: UPDATE parent SET aux = 'bar'; <waiting ...>
step s2u: UPDATE parent SET aux = 'baz';
step s1u: <... completed>
-ERROR: deadlock detected
+error in steps s2u s1u: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s1i: INSERT INTO child VALUES (1, 1);
step s2u: UPDATE parent SET aux = 'baz'; <waiting ...>
step s1u: UPDATE parent SET aux = 'bar';
-ERROR: deadlock detected
step s2u: <... completed>
+error in steps s1u s2u: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s1u2: <... completed>
-ERROR: deadlock detected
+error in steps s2u2 s1u2: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s1u2: <... completed>
-ERROR: deadlock detected
+error in steps s2u2 s1u2: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
step s2u2: <... completed>
+error in steps s1u2 s2u2: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
step s2u2: <... completed>
+error in steps s1u2 s2u2: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s1u2: <... completed>
-ERROR: deadlock detected
+error in steps s2u2 s1u2: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s1u2: <... completed>
-ERROR: deadlock detected
+error in steps s2u2 s1u2: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
step s2u2: <... completed>
+error in steps s1u2 s2u2: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
step s2u2: <... completed>
+error in steps s1u2 s2u2: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1c: COMMIT;
step s2u1: <... completed>
-ERROR: could not serialize access due to concurrent update
+error in steps s1c s2u1: ERROR: could not serialize access due to concurrent update
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
ERROR: current transaction is aborted, commands ignored until end of transaction block
step s2c: COMMIT;
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s1u2: <... completed>
-ERROR: deadlock detected
+error in steps s2u2 s1u2: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s1u2: <... completed>
-ERROR: deadlock detected
+error in steps s2u2 s1u2: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
step s2u2: <... completed>
+error in steps s1u2 s2u2: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
step s2u2: <... completed>
+error in steps s1u2 s2u2: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s1u2: <... completed>
-ERROR: deadlock detected
+error in steps s2u2 s1u2: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
step s1u2: <... completed>
-ERROR: deadlock detected
+error in steps s2u2 s1u2: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
step s2u2: <... completed>
+error in steps s1u2 s2u2: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
step s2u2: <... completed>
+error in steps s1u2 s2u2: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
+++ /dev/null
-Parsed test spec with 2 sessions
-
-starting permutation: s1u1 s1u2 s1c s2u1 s2u2 s2c
-step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
-step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1c: COMMIT;
-step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s2c: COMMIT;
-
-starting permutation: s1u1 s1u2 s2u1 s1c s2u2 s2c
-step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
-step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
-step s1c: COMMIT;
-step s2u1: <... completed>
-ERROR: could not serialize access due to concurrent update
-step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: current transaction is aborted, commands ignored until end of transaction block
-step s2c: COMMIT;
-
-starting permutation: s1u1 s2u1 s1u2 s2u2 s1c s2c
-step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
-step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
-step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1u2: <... completed>
-ERROR: deadlock detected
-step s1c: COMMIT;
-step s2c: COMMIT;
-
-starting permutation: s1u1 s2u1 s1u2 s2u2 s2c s1c
-step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
-step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
-step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1u2: <... completed>
-ERROR: deadlock detected
-step s2c: COMMIT;
-step s1c: COMMIT;
-
-starting permutation: s1u1 s2u1 s2u2 s1u2 s1c s2c
-step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
-step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
-step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
-step s2u2: <... completed>
-step s1c: COMMIT;
-step s2c: COMMIT;
-
-starting permutation: s1u1 s2u1 s2u2 s1u2 s2c s1c
-step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
-step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
-step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
-step s2u2: <... completed>
-step s2c: COMMIT;
-step s1c: COMMIT;
-
-starting permutation: s2u1 s1u1 s1u2 s2u2 s1c s2c
-step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
-step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
-step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1u2: <... completed>
-ERROR: deadlock detected
-step s1c: COMMIT;
-step s2c: COMMIT;
-
-starting permutation: s2u1 s1u1 s1u2 s2u2 s2c s1c
-step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
-step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
-step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1u2: <... completed>
-ERROR: deadlock detected
-step s2c: COMMIT;
-step s1c: COMMIT;
-
-starting permutation: s2u1 s1u1 s2u2 s1u2 s1c s2c
-step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
-step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
-step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
-step s2u2: <... completed>
-step s1c: COMMIT;
-step s2c: COMMIT;
-
-starting permutation: s2u1 s1u1 s2u2 s1u2 s2c s1c
-step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1;
-step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2; <waiting ...>
-step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: deadlock detected
-step s2u2: <... completed>
-step s2c: COMMIT;
-step s1c: COMMIT;
-
-starting permutation: s2u1 s2u2 s1u1 s2c s1u2 s1c
-step s2u1: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s2u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-step s1u1: UPDATE A SET Col1 = 1 WHERE AID = 1; <waiting ...>
-step s2c: COMMIT;
-step s1u1: <... completed>
-step s1u2: UPDATE B SET Col2 = 1 WHERE BID = 2;
-ERROR: could not serialize access due to concurrent update
-step s1c: COMMIT;
step s2i: INSERT INTO child VALUES (2, 1); <waiting ...>
step s1c: COMMIT;
step s2i: <... completed>
-ERROR: could not serialize access due to concurrent update
+error in steps s1c s2i: ERROR: could not serialize access due to concurrent update
step s2u: UPDATE parent SET aux = 'baz';
ERROR: current transaction is aborted, commands ignored until end of transaction block
step s2c: COMMIT;
step s1u: UPDATE parent SET aux = 'bar'; <waiting ...>
step s2u: UPDATE parent SET aux = 'baz';
step s1u: <... completed>
-ERROR: deadlock detected
+error in steps s2u s1u: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s2i: INSERT INTO child VALUES (2, 1);
step s2u: UPDATE parent SET aux = 'baz'; <waiting ...>
step s1u: UPDATE parent SET aux = 'bar';
-ERROR: deadlock detected
step s2u: <... completed>
+error in steps s1u s2u: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
step s1u: UPDATE parent SET aux = 'bar'; <waiting ...>
step s2u: UPDATE parent SET aux = 'baz';
step s1u: <... completed>
-ERROR: deadlock detected
+error in steps s2u s1u: ERROR: deadlock detected
step s1c: COMMIT;
step s2c: COMMIT;
step s1i: INSERT INTO child VALUES (1, 1);
step s2u: UPDATE parent SET aux = 'baz'; <waiting ...>
step s1u: UPDATE parent SET aux = 'bar';
-ERROR: deadlock detected
step s2u: <... completed>
+error in steps s1u s2u: ERROR: deadlock detected
step s2c: COMMIT;
step s1c: COMMIT;
step s1i: INSERT INTO child VALUES (1, 1); <waiting ...>
step s2c: COMMIT;
step s1i: <... completed>
-ERROR: could not serialize access due to concurrent update
+error in steps s2c s1i: ERROR: could not serialize access due to concurrent update
step s1u: UPDATE parent SET aux = 'bar';
ERROR: current transaction is aborted, commands ignored until end of transaction block
step s1c: COMMIT;
return strcmp(stepname, step->name);
}
+/*
+ * If a step caused an error to be reported, print it out and clear it.
+ */
+static void
+report_error_message(Step *step)
+{
+ if (step->errormsg)
+ {
+ fprintf(stdout, "%s\n", step->errormsg);
+ free(step->errormsg);
+ step->errormsg = NULL;
+ }
+}
+
+/*
+ * As above, but reports messages possibly emitted by two steps. This is
+ * useful when we have a blocked command awakened by another one; we want to
+ * report both messages identically, for the case where we don't care which
+ * one fails due to a timeout such as deadlock timeout.
+ */
+static void
+report_two_error_messages(Step *step1, Step *step2)
+{
+ char *prefix;
+
+ prefix = malloc(strlen(step1->name) + strlen(step2->name) + 2);
+ sprintf(prefix, "%s %s", step1->name, step2->name);
+
+ if (step1->errormsg)
+ {
+ fprintf(stdout, "error in steps %s: %s\n", prefix,
+ step1->errormsg);
+ free(step1->errormsg);
+ step1->errormsg = NULL;
+ }
+ if (step2->errormsg)
+ {
+ fprintf(stdout, "error in steps %s: %s\n", prefix,
+ step2->errormsg);
+ free(step2->errormsg);
+ step2->errormsg = NULL;
+ }
+}
+
/*
* Run one permutation
*/
/* Some other step is already waiting: just block. */
try_complete_step(step, 0);
- /* See if this step unblocked the waiting step. */
+ /*
+ * See if this step unblocked the waiting step; report both error
+ * messages together if so.
+ */
if (!try_complete_step(waiting, STEP_NONBLOCK | STEP_RETRY))
+ {
+ report_two_error_messages(step, waiting);
waiting = NULL;
+ }
+ else
+ report_error_message(step);
+ }
+ else
+ {
+ if (try_complete_step(step, STEP_NONBLOCK))
+ waiting = step;
+ report_error_message(step);
}
- else if (try_complete_step(step, STEP_NONBLOCK))
- waiting = step;
}
/* Finish any waiting query. */
if (waiting != NULL)
+ {
try_complete_step(waiting, STEP_RETRY);
+ report_error_message(waiting);
+ }
/* Perform per-session teardown */
for (i = 0; i < testspec->nsessions; i++)
* 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 should call report_error_message shortly after this, to have it
+ * printed and cleared.
+ *
* If the STEP_NONBLOCK flag was specified and the query is waiting to acquire
* a lock, returns true. Otherwise, returns false.
*/
printResultSet(res);
break;
case PGRES_FATAL_ERROR:
+ if (step->errormsg != NULL)
+ {
+ printf("WARNING: this step had a leftover 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",
int session;
char *name;
char *sql;
+ char *errormsg;
};
typedef struct
$$ = malloc(sizeof(Step));
$$->name = $2;
$$->sql = $3;
+ $$->errormsg = NULL;
}
;