Stabilizing Celery / SQL Lab (#2981)

* upgrade celery to 4.0.2
* using Redis for unit tests (sqla broker not supported in Celery 4)
* Setting Celery's soft_time_limit based on `SQLLAB_ASYNC_TIME_LIMIT_SEC` config
* Better error handling in async tasks
* Better statsd logging in async tasks
* show [pending/running] query status in Results tab
* systematically using sqla NullPool on worker (async) to limit number
  of database connections
This commit is contained in:
Maxime Beauchemin
2017-06-20 13:55:03 -07:00
committed by GitHub
parent de88764e93
commit 06fcaa3095
16 changed files with 166 additions and 51 deletions

View File

@@ -155,7 +155,7 @@ export function runQuery(query) {
} else if (msg === null) {
msg = `[${textStatus}] ${errorThrown}`;
}
if (msg.indexOf('The CSRF token is missing') > 0) {
if (msg.indexOf('CSRF token') > 0) {
msg = 'Your session timed out, please refresh your page and try again.';
}
dispatch(queryFailed(query, msg));

View File

@@ -0,0 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Label } from 'react-bootstrap';
import { STATE_BSSTYLE_MAP } from '../constants';
const propTypes = {
query: PropTypes.object.isRequired,
};
export default function QueryStateLabel({ query }) {
const bsStyle = STATE_BSSTYLE_MAP[query.state];
return (
<Label className="m-r-3" bsStyle={bsStyle}>
{query.state}
</Label>
);
}
QueryStateLabel.propTypes = propTypes;

View File

@@ -9,9 +9,9 @@ import VisualizeModal from './VisualizeModal';
import ResultSet from './ResultSet';
import ModalTrigger from '../../components/ModalTrigger';
import HighlightedSql from './HighlightedSql';
import { STATE_BSSTYLE_MAP } from '../constants';
import { fDuration } from '../../modules/dates';
import { storeQuery } from '../../../utils/common';
import QueryStateLabel from './QueryStateLabel';
const propTypes = {
columns: PropTypes.array,
@@ -164,9 +164,7 @@ class QueryTable extends React.PureComponent {
}
q.state = (
<div>
<span className={'m-r-3 label label-' + STATE_BSSTYLE_MAP[q.state]}>
{q.state}
</span>
<QueryStateLabel query={query} />
{errorTooltip}
</div>
);

View File

@@ -6,6 +6,7 @@ import shortid from 'shortid';
import VisualizeModal from './VisualizeModal';
import HighlightedSql from './HighlightedSql';
import FilterableTable from '../../components/FilterableTable/FilterableTable';
import QueryStateLabel from './QueryStateLabel';
const propTypes = {
actions: PropTypes.object,
@@ -165,6 +166,7 @@ export default class ResultSet extends React.PureComponent {
return (
<div>
<img className="loading" alt="Loading..." src="/static/assets/images/loading.gif" />
<QueryStateLabel query={query} />
{progressBar}
</div>
);

View File

@@ -237,8 +237,7 @@ export const sqlLabReducer = function (state, action) {
for (const id in action.alteredQueries) {
const changedQuery = action.alteredQueries[id];
if (!state.queries.hasOwnProperty(id) ||
(state.queries[id].changedOn !== changedQuery.changedOn &&
state.queries[id].state !== 'stopped')) {
state.queries[id].state !== 'stopped') {
if (changedQuery.changedOn > queriesLastUpdate) {
queriesLastUpdate = changedQuery.changedOn;
}