AFAIK, the scheduler is responsible, e.x.:
SETUP (e.x.):
scheduler.queue_task(
'test__task_insert', application_name='app', repeats=0, period=60, timeout=3600, retry_failed=-1)
def task_insert():
db.table.insert(title='abc')
db.commit()
# db.close() -- same problem, doesn't matter
scheduler = Scheduler(db, {
'test__task_insert': task_insert
})
log output, when taks runs:
....
2018-11-13 13:14:11 EET LOG: duration: 0.029 ms statement: BEGIN
2018-11-13 13:14:11 EET LOG: duration: 0.340 ms statement: SELECT
scheduler_worker.id, scheduler_worker.worker_name, scheduler_worker.first_heartbeat, scheduler_worker.last_heartbeat, scheduler_worker.status, scheduler_worker.is_ticker, scheduler_worker.group_names, scheduler_worker.worker_stats FROM scheduler_worker WHERE (scheduler_worker.worker_name = 'web2py#8228');
2018-11-13 13:14:11 EET LOG: duration: 0.305 ms statement: UPDATE scheduler_worker SET status='ACTIVE',last_heartbeat='2018-11-13 13:14:11',worker_stats='{"status": "RUNNING", "errors": 0, "workers": 1, "queue": 1, "empty_runs": 0, "sleep": 3, "distribution": {"main": {"workers": [{"c": 1, "name": "web2py#8228"}]}}, "total": 1}' WHERE (scheduler_worker.worker_name = 'web2py#8228');
2018-11-13 13:14:11 EET LOG: duration: 1.890 ms statement: COMMIT
2018-11-13 13:14:11 EET LOG: duration: 0.067 ms statement: BEGIN
2018-11-13 13:14:11 EET LOG: duration: 0.046 ms statement: SET CLIENT_ENCODING TO 'UTF8'
2018-11-13 13:14:11 EET LOG: duration: 0.020 ms statement: SET standard_conforming_strings=on;
2018-11-13 13:14:11 EET LOG: duration: 0.047 ms statement: COMMIT
2018-11-13 13:14:12 EET LOG: duration: 0.029 ms statement: BEGIN
2018-11-13 13:14:12 EET LOG: duration: 2.413 ms statement: INSERT INTO table(title) VALUES ('abc');
2018-11-13 13:14:12 EET LOG: duration: 2.594 ms statement: COMMIT
2018-11-13 13:14:12 EET LOG: could not receive data from client: Connection reset by peer
2018-11-13 13:14:12 EET LOG: duration: 0.029 ms statement: BEGIN
2018-11-13 13:14:12 EET LOG: duration: 0.285 ms statement: DELETE FROM scheduler_run WHERE (
scheduler_run.id = 967703);
2018-11-13 13:14:12 EET LOG: duration: 0.306 ms statement: UPDATE scheduler_task SET status='QUEUED',next_run_time='2018-11-13 13:15:11',times_run=93796,times_failed=0 WHERE (
scheduler_task.id = 371);
2018-11-13 13:14:12 EET LOG: duration: 2.426 ms statement: COMMIT
2018-11-13 13:14:12 EET LOG: duration: 0.024 ms statement: BEGIN
....
PROBLEM: "2018-11-13 13:14:12 EET LOG: could not receive data from client: Connection reset by peer"
We have ~20 ish active schedulers, so the log gets flooded a lot, basically:
2018-11-13 09:21:00 EET LOG: could not receive data from client: Connection reset by peer
2018-11-13 09:21:00 EET LOG: could not receive data from client: Connection reset by peer
2018-11-13 09:21:00 EET LOG: could not receive data from client: Connection reset by peer
2018-11-13 09:21:16 EET LOG: could not receive data from client: Connection reset by peer
2018-11-13 09:21:46 EET LOG: could not receive data from client: Connection reset by peer
2018-11-13 09:22:00 EET LOG: could not receive data from client: Connection reset by peer
2018-11-13 09:22:00 EET LOG: could not receive data from client: Connection reset by peer
2018-11-13 09:22:01 EET LOG: could not receive data from client: Connection reset by peer