Open jc-harrison opened 5 years ago
A possible solution would be to get the list of all queries known to redis, and wait for all of these to be in a finished state before resetting FlowDB and redis. This wouldn't work in any situation where new queries could be submitted during the wait/reset process, but should be sufficient for resetting between integration tests.
At the start of each integration test, the cache and redis are reset. However, we don't check that all queries started by the previous test have finished before resetting, which can lead to errors. We should either wait for all running queries to finish, or explicitly kill them before resetting.
Note: I tried explicitly killing all queries by executing
"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND application_name='{fm_conn.app_name}';"
, but this resulted in a lot of tests failing withInterfaceError: connection already closed
. Also, I think even this would be insufficient, because if a thread has been started (inQuery.thread_pool_executor
) but hasn't started executing any SQL yet then it won't be killed by thepg_terminate_backend
.