Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

405
Views
postgresql return error : ERROR: canceling statement due to user request

I'm using postgresql 9.6,it's ok to execute in psql command:

  select pg_cancel_backend(a.pid)  from pg_locks a join pg_class b on a.relation = b.oid join pg_stat_activity c on a.pid = c.pid where c.datname = 'mydb' and a.mode like '%AccessShareLock%'; 

However, it prompts an error : "ERROR: canceling statement due to user request" when I execute the following scripts:

/app/postgres/pgsql/bin/psql -h "127.0.0.1" -p 6661 -U "postgres" -d "mydb" -tc "select pg_cancel_backend(a.pid)  from pg_locks a
> join pg_class b on a.relation = b.oid
> join pg_stat_activity c on a.pid = c.pid
> where c.datname = 'mydb' and a.mode like '%AccessShareLock%';"

what is the difference between this two methods?

enter image description here

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Both methods execute the same statement, so the end result is the same. However, when you use the psql command, you can run it directly from the shell. The first command requires that you are already connected to postgres.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!