如何在Redshift中超时空闲用户会话?

时间:2017-03-08 21:43:10

标签: postgresql amazon-web-services timeout amazon-redshift

我正在寻找一种方法来终止在Redshift中处于非活动状态或打开任意时间的用户会话。我注意到在 STV_SESSIONS 中我打开了大量会话,通常是针对同一个用户,有时几天前已经初始化。虽然我知道这可能是一些更大问题的症状,因为有些东西关闭了Redshift,我希望有一个可配置的超时解决方案。

在AWS文档中,我找到了 PG_TERMINATE_BACKEND http://docs.aws.amazon.com/redshift/latest/dg/PG_TERMINATE_BACKEND.html),但我希望有更自动的解决方案。

2 个答案:

答案 0 :(得分:1)

您可以在AWS redshift中使用Workload Management Configuration。您可以在其中设置用户组,查询组和超时会话。您可以将所有相同的用户组合在一起并为其分配组名称并为其设置超时会话。

这是我的方式。根据您的优先级设置查询队列,然后设置用户组的并发级别和以毫秒为单位的超时。

enter image description here


有关更多信息,请参阅AWS文档。
来源 - Workload Management
- Configuring Workload Management

它非常简单直接。
如果我做了一个错误的假设,请发表评论,我将重新调整我的答案。

答案 1 :(得分:0)

超时仅用于超时查询,而不用于会话。

超时(毫秒)

The maximum time, in milliseconds, queries can run before being canceled. If a read-only query, such as a SELECT statement, is canceled due to a WLM timeout, WLM attempts to route the query to the next matching queue based on the WLM Queue Assignment Rules. If the query doesn't match any other queue definition, the query is canceled; it is not assigned to the default queue. For more information, see WLM Query Queue Hopping. WLM timeout doesn’t apply to a query that has reached the returning state. To view the state of a query, see the STV_WLM_QUERY_STATE system table.

JSON property: max_execution_time