# RDS上创建GIN索引的会话周期性出现大量Lock:relation等待

**URL:** <https://meta.discourse.org/t/discourse-on-rds-periodically-results-into-many-lock-relation-waits-for-create-gin-index-sessions/270894>\
**Category:** Self-hosting\
**Tags:** unsupported-install\
**Created:** [2023 年7 月 7 日 15:23 UTC](https://meta.discourse.org/t/discourse-on-rds-periodically-results-into-many-lock-relation-waits-for-create-gin-index-sessions/270894 "2023-07-07T15:23:27Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![venkytn](https://avatars.discourse-cdn.com/v4/letter/v/c37758/32.png) [@venkytn](https://meta.discourse.org/u/venkytn)\
发布日期： [2023 年7 月 7 日 15:23 UTC](https://meta.discourse.org/t/discourse-on-rds-periodically-results-into-many-lock-relation-waits-for-create-gin-index-sessions/270894/1 "2023-07-07T15:23:27Z")

</div>

我们偶尔会发现，在 `post_search_data` 上创建 GIN 索引会导致性能洞察中出现大量的 `Lock:relations`。终止创建此索引的会话可以释放所有被阻塞的会话。有趣的是，该索引使用了“concurrently”，这本不应该是一个阻塞操作。另外，它为什么会加上“temp”前缀也很有趣。

```plaintext
CREATE INDEX CONCURRENTLY temp_idx_recent_regular_post_search_data ON post_search_data USING GIN(search_data) WHERE NOT private_message AND post_id >= 12431619

```

我也尝试将 `idle_in_transaction_session_timeout` 从最初设置的 1 天减少到 10 分钟，但没有起到任何作用。其他人遇到过类似的问题吗？如果有，你们是如何处理的？

我们的版本是 Discourse 2.7.0 和 Postgres 13.8。应用程序和数据库不在 Docker 中，而是单独托管（ec2、rds）。

---

_[View the full topic](https://meta.discourse.org/t/discourse-on-rds-periodically-results-into-many-lock-relation-waits-for-create-gin-index-sessions/270894)._
