summaryrefslogtreecommitdiff
path: root/src/backend/access/transam/parallel.c
diff options
context:
space:
mode:
authorRobert Haas2016-01-30 13:35:56 +0000
committerRobert Haas2016-02-01 21:13:15 +0000
commit874b3b86a898d07beea6e2143ab9827153cc8fc0 (patch)
tree9634e659e5ce849d59d0d1440f806b5fab6135da /src/backend/access/transam/parallel.c
parent1b4d0cffd00248df5c1c57239284e985ba82cf86 (diff)
Hack on lock transfer stuff.gathertest
XXX: I don't think this is the right design. It will require the workers to wait for the leader to perform the associated lock acquisitions, and then the leader will need to tell them, afterwards, that they can go exit. There's no obvious way to make that signalling work. Instead, I wonder if we shouldn't including bookkeeping information in the PROCLOCK structures somehow, so that the worker actually reassigns the locks to the leader directly. However, that has a couple of problems. One is that the leader might pick a bad time to die, orphaning locks. Another is that the leader wouldn't know how to associate the locks with its own resource owners. Hmm, need to think more about this.
Diffstat (limited to 'src/backend/access/transam/parallel.c')
-rw-r--r--src/backend/access/transam/parallel.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 3915750419..31b23a785b 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -807,6 +807,33 @@ HandleParallelMessage(ParallelContext *pcxt, int i, StringInfo msg)
break;
}
+ case 'L': /* Lock information */
+ {
+ int i;
+
+ Assert(msg->len > 1 && (msg->len % sizeof(LOCALLOCKTAG)) == 1);
+
+ for (i = 1; i < msg->len; i += sizeof(LOCALLOCKTAG))
+ {
+ LOCALLOCKTAG locallocktag;
+
+ memcpy((char *) &locallocktag, &msg->data[i], sizeof(LOCALLOCKTAG));
+ /* XXX. Now what? */
+#if 0
+ ereport(NOTICE,
+ (errmsg("worker has lock %u/%u/%u/%u type %u method %u mode %u",
+ locallocktag.lock.locktag_field1,
+ locallocktag.lock.locktag_field2,
+ locallocktag.lock.locktag_field3,
+ locallocktag.lock.locktag_field4,
+ locallocktag.lock.locktag_type,
+ locallocktag.lock.locktag_lockmethodid,
+ locallocktag.mode)));
+#endif
+ }
+ break;
+ }
+
case 'X': /* Terminate, indicating clean exit */
{
pfree(pcxt->worker[i].error_mqh);
@@ -1038,6 +1065,11 @@ ParallelWorkerMain(Datum main_arg)
/* Must pop active snapshot so resowner.c doesn't complain. */
PopActiveSnapshot();
+ /* Send a message to the leader with the heavyweight locks we still retain. */
+ pq_beginmessage(&msgbuf, 'L');
+ if (GetMyLocks(&msgbuf) != 0)
+ pq_endmessage(&msgbuf);
+
/* Shut down the parallel-worker transaction. */
EndParallelWorkerTransaction();