fix(celery): Reset DB connection pools for forked worker processes (#13350)

* Reset sqlalchemy connection pool on celery process fork

* Fix race condition with async chart loading state

* pylint: ignore

* prettier
This commit is contained in:
Rob DiCiuccio
2021-02-26 08:05:40 -08:00
committed by GitHub
parent 1697e1e3b1
commit b4ca39ceeb
4 changed files with 22 additions and 6 deletions

View File

@@ -119,8 +119,7 @@ const initAsyncEvents = (options: AsyncEventOptions) => {
};
const processEvents = async () => {
const state = store.getState();
const queuedComponents = getPendingComponents(state);
let queuedComponents = getPendingComponents(store.getState());
const eventArgs = lastReceivedEventId
? { last_id: lastReceivedEventId }
: {};
@@ -128,6 +127,9 @@ const initAsyncEvents = (options: AsyncEventOptions) => {
if (queuedComponents && queuedComponents.length) {
try {
const { result: events } = await fetchEvents(eventArgs);
// refetch queuedComponents due to race condition where results are available
// before component state is updated with asyncJobId
queuedComponents = getPendingComponents(store.getState());
if (events && events.length) {
const componentsByJobId = queuedComponents.reduce((acc, item) => {
acc[item.asyncJobId] = item;