# Found a fix for Postgres plugin

**URL:** <https://community.temporal.io/t/found-a-fix-for-postgres-plugin/547>\
**Category:** Community Support\
**Tags:** cadence\
**Created:** [August 28, 2020, 1:27am UTC](https://community.temporal.io/t/found-a-fix-for-postgres-plugin/547 "2020-08-28T01:27:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chf75](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@chf75](https://community.temporal.io/u/chf75)\
**Post date:** [August 28, 2020, 1:27am UTC](https://community.temporal.io/t/found-a-fix-for-postgres-plugin/547/1 "2020-08-28T01:27:29Z")

</div>

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)`
```

---

<div class="post-metadata">

**Author:** ![chf75](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@chf75](https://community.temporal.io/u/chf75)\
**Post date:** [August 28, 2020, 1:34am UTC](https://community.temporal.io/t/found-a-fix-for-postgres-plugin/547/2 "2020-08-28T01:34:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ringods](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ringods/32/21_2.png) [@ringods](https://community.temporal.io/u/ringods)\
**Post date:** [September 3, 2020, 12:13pm UTC](https://community.temporal.io/t/found-a-fix-for-postgres-plugin/547/4 "2020-09-03T12:13:38Z")

</div>

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

> **[temporalio/temporal](https://github.com/temporalio/temporal/pulls)**
>
> Temporal service and CLI. Contribute to temporalio/temporal development by creating an account on GitHub.

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.

---

<div class="post-metadata">

**Author:** ![chf75](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@chf75](https://community.temporal.io/u/chf75)\
**Post date:** [September 3, 2020, 4:21pm UTC](https://community.temporal.io/t/found-a-fix-for-postgres-plugin/547/5 "2020-09-03T16:21:37Z")

</div>

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

> <https://github.com/uber/cadence/pull/3484>

---

<div class="post-metadata">

**Author:** ![chf75](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@chf75](https://community.temporal.io/u/chf75)\
**Post date:** [September 8, 2020, 7:38pm UTC](https://community.temporal.io/t/found-a-fix-for-postgres-plugin/547/6 "2020-09-08T19:38:31Z")

</div>

Fixed now in Cadence. See [https://github.com/uber/cadence/pull/3498](https://github.com/uber/cadence/pull/3498)

---

<div class="post-metadata">

**Author:** ![shawn](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@shawn](https://community.temporal.io/u/shawn)\
**Post date:** [September 8, 2020, 11:10pm UTC](https://community.temporal.io/t/found-a-fix-for-postgres-plugin/547/7 "2020-09-08T23:10:07Z")

</div>

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