小编Paw*_*ara的帖子

Google Cloud SQL PostrgreSQL上的pg_stat_statements_reset()权限被拒绝

主要问题

SELECT pg_stat_statements_reset();由于权限不足,我无法执行该功能以概要分析查询优化中的更改。错误消息显示为: permission denied for function pg_stat_statements_reset

我想知道是否还有其他方法可以在Cloud SQL PostgreSQL上重置pg_stats?

环境

  • PG版本:x86_64-pc-linux-gnu上的PostgreSQL 9.6.6,由gcc编译(Ubuntu 4.8.4-2ubuntu1〜14.04.3)4.8.4,64位
  • 平台:Google Cloud SQL PostgreSQL
  • 用户:具有cloudsqlsuperuser角色的默认postgres用户

尝试的步骤

我已经找到了关于该主题的先前答案,该答案建议pg_stat_statements_reset()应与通过云控制台创建的默认postgres用户一起使用。但是,列出的解决方案不起作用,它返回相同的权限被拒绝错误

相关问题

postgresql google-cloud-sql

5
推荐指数
1
解决办法
384
查看次数

Google Cloud Functions 实现互斥的模式是什么

我正在使用 https 触发的 Google Cloud Functions 来处理客户端请求以执行数据库写入。数据的结构方式使得大多数并行写入都不会导致损坏。

在极少数情况下,我需要防止同一项目同时发生多个写入操作。在功能级别上锁定对某些资源的访问的常见模式有哪些。我正在寻找一些“类似互斥体”的功能。

我正在考虑一些外部服务,可以授予或拒绝对请求函数实例的资源的访问,但连接开销会很大 - 每次握手等。

根据要求添加了一个示例。在这种特定情况下,重组数据以跟踪更新并不是合适的解决方案。

import * as admin from "firebase-admin";

function updateUserState(userId: string) {
    // Query current state
    admin
        .database()
        .ref()
        .child(`/users/${userId}/state`)
        .once("value")
        .then(snapshot => {
            return snapshot.val() || 0;
        })
        .then(currentState => 
            // Perform some operation
            modifyStateAsync(currentState)
        )
        .then(newState => {
            admin
                .database()
                .ref()
                .child(`/users/${userId}/state`)
                .set(newState);
        });
}
Run Code Online (Sandbox Code Playgroud)

google-cloud-platform google-cloud-functions

5
推荐指数
1
解决办法
1823
查看次数