Skip to content

Fix race condition when fetching results in SQL Lab - #7198

Merged
xtinec merged 2 commits into
apache:lyftgafrom
lyft:VIZ-193
Apr 2, 2019
Merged

xtinec merged 2 commits into
apache:lyftgafrom
lyft:VIZ-193

Conversation

@betodealmeida

@betodealmeida betodealmeida commented Apr 2, 2019 •

Copy link
Copy Markdown
Member
SUMMARY

There's a race condition causing results to not be returned by SQL Lab. An eager commit saves the query object with its status set to SUCCESS, but only later it updates the resultsKey:

    query.status = QueryStatus.SUCCESS
    session.commit()  # HERE
    ...
    if store_results:
        key = str(uuid.uuid4())
        ...
        query.results_key = key
    session.commit()

I simply deleted the first commit, and now the results are always returned.

I also fixed the execute_sql_statement function. It was taking an argument return_results which was not being used anywhere.

TEST PLAN

I ran queries in SQL Lab, and they returned 100% of the time. Before, occasionally they wouldn't return anything because state was set to SUCCESS, but the query object had no resultsKeys attribute.

ADDITIONAL INFORMATION
[ ] Has associated issue:
[ ] Changes UI
[ ] Requires DB Migration. Confirm DB Migration upgrade and downgrade tested.
[ ] Introduces new feature or API
[ ] Removes existing feature or API
[x] Fixes bug
[ ] Refactors code
[ ] Adds test(s)
REVIEWERS

@xtinec @DiggidyDave @khtruong @enricoberti

@xtinec xtinec left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!!!!!

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #7198 into lyftga will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           lyftga    #7198      +/-   ##
==========================================
- Coverage   64.52%   64.51%   -0.01%     
==========================================
  Files         424      424              
  Lines       20684    20682       -2     
  Branches     2268     2268              
==========================================
- Hits        13346    13344       -2     
  Misses       7216     7216              
  Partials      122      122
Impacted Files Coverage Δ
superset/sql_lab.py 76.37% <100%> (-0.26%) ⬇️
superset/views/core.py 75% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd56716...fac8b4d. Read the comment docs.

@xtinec
xtinec merged commit fcebb80 into apache:lyftga Apr 2, 2019
xtinec pushed a commit that referenced this pull request Apr 2, 2019
* Fix race condition when fetching results in SQL Lab

* Fix lint
michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request Apr 8, 2019
* Fix race condition when fetching results in SQL Lab

* Fix lint

(cherry picked from commit ca6a73b)
michellethomas added a commit that referenced this pull request Apr 8, 2019
* Fix race condition when fetching results in SQL Lab

* Fix lint

(cherry picked from commit ca6a73b)
michellethomas added a commit that referenced this pull request Apr 8, 2019
* Fix race condition when fetching results in SQL Lab

* Fix lint

(cherry picked from commit ca6a73b)
(cherry picked from commit 52473c5)
@betodealmeida betodealmeida mentioned this pull request May 3, 2019
1 of 12 tasks
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 First shipped in 0.34.0 labels Feb 28, 2024
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
…ache#7242)

* Fix race condition when fetching results in SQL Lab

* Fix lint

(cherry picked from commit ca6a73b)
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
* Fix race condition when fetching results in SQL Lab

* Fix lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 First shipped in 0.34.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants