2
我有一個針對PostgreSQL數據庫執行查詢(python腳本紅移它運行在我的本地機器上完美的罰款:psycopg2時掛起的「選擇」對INFORMATION_SCHEMA在CentOS VS蟒蛇執行的語句2.6
Ubuntu 12.10,
python 2.7
psycog.__version__ = '2.5.3 (dt dec pq3 ext)'
但當我執行上AWS
CentOS 6.5
Python 2.6
psycog.__version__ = '2.5.3 (dt dec pq3 ext)'
這裏從我的督促設備的某些查詢掛是代碼:
import psycopg2
con = psycopg2.connect(**{<my_connection_params>}})
curs = con.cursor()
# This works perfectly fine on both machines !!!
curs.execute("""SELECT table_name FROM information_schema.tables
WHERE table_schema='public' AND table_type='BASE TABLE'""")
# This one hangs on AWS, but works fine from my laptop
curs.execute('select column_name from information_schema.columns')
當我連接到db
和運行查詢,以查看正在運行的進程,我可以看到這一點:
select pid, trim(user_name), starttime, substring(query,1,20)
from stv_recents
where status='Running';
我可以看到這個查詢。
這裏是一個strace -p
:
ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x3aaa00f710}, {0x3ab1027010, [], SA_RESTORER|SA_RESTART, 0x3aaa00f710}, 8) = 0
gettimeofday({1403280035, 826010}, NULL) = 0
rt_sigprocmask(SIG_BLOCK, [PIPE], [], 8) = 0
write(3, "\27\3\1\0 5\351Br$\331\30\00563\v\211f\325\367\210\331\331\253\300\310\240"..., 122) = 122
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
poll([{fd=3, events=POLLIN|POLLERR}], 1, -1) =
在服務器端'pg_stat_activity'有上查詢'waiting'標誌?如果是這樣,請檢查'pg_locks'並查看是否有人爲DDL鎖定了一個表。 –