此问题特定于Web2py Framework中的调度程序。
我正在使用调度程序作为Linux服务。
我创建了一个文件/etc/systemd/system/web2py-sched.service
[Unit]
Description=Web2Py scheduler service
[Service]
ExecStart=/usr/bin/python /home/www-data/web2py/web2py.py -K myApp
Type=simple
Restart=always
[Install]
WantedBy=multi-user.target
然后安装服务调用:
sudo systemctl enable /etc/systemd/system/web2py-sched.service
systemctl start /etc/systemd/system/web2py-sched
当我检查Postgres状态时,我看到有些进程处于“空闲”状态。
may@myApp:/home/www-data/web2py/scmyAppts$ sudo systemctl status postgresql@9.5-main
● postgresql@9.5-main.service - PostgreSQL Cluster 9.5-main
Loaded: loaded (/lib/systemd/system/postgresql@.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2018-10-16 15:39:25 PDT; 1 weeks 1 days ago
Main PID: 28202 (postgres)
CGroup: /system.slice/system-postgresql.slice/postgresql@9.5-main.service
├─10956 postgres: may mydb ::1(60654) idle in transaction
├─10957 postgres: may mydb ::1(60656) idle in transaction
├─13421 postgres: may mydb 10.5.77.35(51998) idle
├─13422 postgres: may mydb 10.5.77.35(52004) idle
├─13423 postgres: may postgres 10.5.77.35(52005) idle
├─13425 postgres: may mydb 10.5.77.35(52007) idle
├─13433 postgres: may mydb 10.5.77.35(52332) idle
├─28202 /usr/lib/postgresql/9.5/bin/postgres -D /var/lib/postgresql/9.5/main -c config_file=/etc/postgresql/9.5/main/postgresql.conf
├─28204 postgres: checkpointer process
├─28205 postgres: writer process
├─28206 postgres: wal writer process
├─28207 postgres: autovacuum launcher process
├─28208 postgres: stats collector process
├─30475 postgres: may mydb ::1(59838) idle
├─30476 postgres: may mydb ::1(59840) idle in transaction
└─30500 postgres: may mydb ::1(59842) idle
当我发现很少有进程处于空闲状态并且事务并且我的数据库查询正在超时时,我检查了哪个表正在获取锁。
SELECT relation, pid, mode, granted, relname
FROM pg_locks
INNER JOIN pg_stat_user_tables
ON pg_locks.relation = pg_stat_user_tables.relid
WHERE pg_locks.pid='30476';
relation pid mode granted relname
16553 30476 AccessShareLock TRUE scheduler_task
请为此提供帮助,我已经彻底了解了我的调度程序代码,并且在每次事务之后都会调用db.commit()。
版本:
Version
2.17.2-stable+timestamp.2018.10.06.18.54.02
(Running on nginx/1.10.3, Python 2.7.12)
web2py is up to date
答案 0 :(得分:0)
由服务启动dates.reduce((a, b) => {
assert([1, 2, 3, 4, 5].includes(a.day()), 'day is a saturday or sunday, wrong.');
assert(b > a, 'date is not forward in time.');
return b; // here
});
配置的您的应用是否真的称为“ myApp”?
您必须通过名称指定您的应用程序。 “ myapp”只是一个占位符。
问候克莱门斯