Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not run db cluster script successfully #320

Open
dadiorchen opened this issue May 23, 2021 · 0 comments
Open

Can not run db cluster script successfully #320

dadiorchen opened this issue May 23, 2021 · 0 comments

Comments

@dadiorchen
Copy link
Collaborator

Script: assign-new-trees-to-clusters.js
will throw error when running to this place:

await client.query('BEGIN');
await client.query('COMMIT');
await client.query('BEGIN');
const refresh = {
text: `REFRESH MATERIALIZED VIEW CONCURRENTLY active_tree_region`
}
await client.query(refresh);
await client.query('COMMIT');

The error:

   9962 error: permission denied for materialized view active_tree_region
   9963   ¦ at Connection.parseE (/root/treetracker-web-map/node_modules/pg/lib/connection.js:546:11)
   9964   ¦ at Connection.parseMessage (/root/treetracker-web-map/node_modules/pg/lib/connection.js:371:19)
   9965   ¦ at TLSSocket.<anonymous> (/root/treetracker-web-map/node_modules/pg/lib/connection.js:114:22)
   9966   ¦ at TLSSocket.emit (events.js:310:20)
   9967   ¦ at addChunk (_stream_readable.js:286:12)
   9968   ¦ at readableAddChunk (_stream_readable.js:268:9)
   9969   ¦ at TLSSocket.Readable.push (_stream_readable.js:209:10)
   9970   ¦ at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)
   9971 (node:4212) UnhandledPromiseRejectionWarning: ReferenceError: client is not defined
   9972   ¦ at /root/treetracker-web-map/src/cron/assign-new-trees-to-clusters.js:158:5
   9973   ¦ at processTicksAndRejections (internal/process/task_queues.js:97:5)
   9974 (node:4212) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by thro
   9975 wing inside of an async function without a catch block, or by rejecting a promise which was not handled with .c
   9976 atch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=
   9977 strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
   9978 (node:4212) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise r
   9979 ejections that are not handled will terminate the Node.js process with a non-zero exit code.

To manually run it in psql:

  10013 treetracker=> REFRESH MATERIALIZED VIEW CONCURRENTLY active_tree_region;
  10014 ERROR:  permission denied for materialized view active_tree_region
  10015 CONTEXT:  SQL statement "DELETE FROM public.active_tree_region mv WHERE ctid OPERATOR(pg_catalog.=) ANY (SELECT
  10016  diff.tid FROM pg_temp_10.pg_temp_22060_2 diff WHERE diff.tid IS NOT NULL AND diff.newdata IS NULL)"
  10017 treetracker=> \q
  10018 root@map-api:~/treetracker-web-map# psql postgresql://treetracker:xi7w7jb5m5xxn4m1@db-postgresql-sfo2-40397-do-
  10019 user-1067699-0.db.ondigitalocean.com:25060/treetracker?ssl=true
  10020 psql (10.16 (Ubuntu 10.16-0ubuntu0.18.04.1), server 11.11)
  10021 WARNING: psql major version 10, server major version 11.
  10022   ¦ ¦ ¦ ¦Some psql features might not work.
  10023 SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
  10024 Type "help" for help.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant