Found a fix for Postgres plugin

Not all fields were getting updated in the conflict case. Here’s the fix:

diff --git a/common/persistence/sql/sqlplugin/postgres/execution_maps.go b/common/persistence/sql/sqlplugin/postgres/execution_maps.go
index dc518896..d0044bbf 100644
--- a/common/persistence/sql/sqlplugin/postgres/execution_maps.go
+++ b/common/persistence/sql/sqlplugin/postgres/execution_maps.go
@@ -45,15 +45,12 @@ run_id = $4`
        setKeyInMapQueryTemplate = `INSERT INTO %[1]v
 (shard_id, domain_id, workflow_id, run_id, %[4]v, %[2]v)
 VALUES
 (:shard_id, :domain_id, :workflow_id, :run_id, :%[4]v, %[3]v)
 ON CONFLICT (shard_id, domain_id, workflow_id, run_id, %[4]v) DO UPDATE
-  SET shard_id = excluded.shard_id,
-      domain_id = excluded.domain_id,
-      workflow_id = excluded.workflow_id,
-         run_id = excluded.run_id,
-      %[4]v = excluded.%[4]v `
+  SET (shard_id, domain_id, workflow_id, run_id, %[4]v, %[2]v)
+  = (:shard_id, :domain_id, :workflow_id, :run_id, :%[4]v, %[3]v)`

Steps to reproduce one class of problems caused by this bug:

  1. Poll for an activity.
  2. Bounce the history node.
  3. Attempt to complete the activity. Receive “activity not found”.

Expected behavior:
In step 3, the activity completion should succeed.

@chf75 can you submit this as a pull request on the Github repository?

As a Temporal user, I would like to get PostgreSQL also in a production ready state ASAP. I assume your fix helps getting to that point.

The dust is still settling on the Cadence pull request. I think there is a piece missing.

Fixed now in Cadence. See https://github.com/uber/cadence/pull/3498

Great! I will dig into this by the end of the week and should have this ported/verified fixed in our next release.

1 Like