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 2022/07/20 14:16:19 UTC

[GitHub] [superset] zhaoyongjie commented on pull request #20780: fix: unexpected commit causes pytest failure

zhaoyongjie commented on PR #20780:
URL: https://github.com/apache/superset/pull/20780#issuecomment-1190344225

   > Can you provide more context about this? How is the `autoflush` rule changed?
   
   The test case `tests/integration_tests/sqla_models_tests.py::TestDatabaseModel::test_fetch_metadata_for_updated_virtual_table` has a line as following, the `fetch_metadata(commit=False)` means that don't perform `commit` immediately in the function call. 
   
   https://github.com/apache/superset/blob/81bd4968d0a916cb2a20e47b20e31a1434be4f46/tests/integration_tests/sqla_models_tests.py#L454-L456
   
   but this transaction was interrupted by `get_or_create_db`, ---- the `commit()` would be executed whenever call the `get_or_create_db`.
   
   https://github.com/apache/superset/blob/81bd4968d0a916cb2a20e47b20e31a1434be4f46/superset/utils/database.py#L34-L64
   
   The strange thing is that this only happens under Postgres, and only after the [SQLAlchemy update](https://github.com/apache/superset/pull/19890). 
   
   You can observe that [L44](https://github.com/apache/superset/blob/81bd4968d0a916cb2a20e47b20e31a1434be4f46/superset/utils/database.py#L44) has a call `autoflash(False)`. This means that the **select statement** is also executed inside the transaction. 
   
   Sorry I didn't delve into SQLAlchmey and PG dialects to continue research, ----- just remove autoflash(False) and prevent execute commit() if no need.
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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