You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/11/18 23:45:35 UTC

[GitHub] [incubator-superset] betodealmeida opened a new pull request #8594: Create new session for tab migration

betodealmeida opened a new pull request #8594: Create new session for tab migration
URL: https://github.com/apache/incubator-superset/pull/8594
 
 
   ### CATEGORY
   
   Choose one
   
   - [X] Bug Fix
   - [ ] Enhancement (new features, refinement)
   - [ ] Refactor
   - [ ] Add tests
   - [ ] Build / Development Environment
   - [ ] Documentation
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   Friday we turned on the `SQLLAB_BACKEND_PERSISTENCE` at Lyft, and noticed a deadlock when migrating SQL Lab tabs from `localStorage` to the backend:
   
   ```
   sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1213, 'Deadlock found when trying to get lock; try restarting transaction')
   [SQL: INSERT INTO tab_state (created_on, changed_on, extra_json, user_id, label, active, database_id, `schema`, `sql`, query_limit, latest_query_id, autorun, template_params, created_by_fk, changed_by_fk) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)]
   [parameters: (datetime.datetime(2019, 11, 16, 1, 39, 45, 903405), datetime.datetime(2019, 11, 16, 1, 39, 45, 903410), '{}', '1963', 'dim_applicants', 1, 7, None, 'select * from events_annotated.event_ride_requested limit 10', None, None, 0, None, 1963, 1963)]
   ```
   
   Note that there was no data loss, and the tabs were migrated successfully on a refresh.
   
   I tried to repro this locally, migrating 20 tabs to a MySQL database, but I wasn't able to hit the deadlock. Looking at the code, it seems that we reuse the same session across all requests, so I refactored it to create a new session for each request.
   
   @mistercrunch do you think this would fix the problem? I'm not super familiar with SQL Alchemy, but from what I read this should work.
   
   <!-- ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF -->
   <!--- Skip this if not applicable -->
   
   ### TEST PLAN
   <!--- What steps should be taken to verify the changes -->
   
   I wasn't able to repro the original bug, but ran this code to ensure that it still works.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] 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
   
   ### REVIEWERS
   
   @mistercrunch 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org