Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: temporarily disconnect metadata db during long analytics queries #916

Closed
wants to merge 7 commits into from

Conversation

mistercrunch
Copy link
Member

@mistercrunch mistercrunch commented Dec 5, 2024

Tried some things ... having issues recreating the scoped session.

Hitting a wall with this message - Instance <Database at 0xffff7c5305e0> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: https://sqlalche.me/e/14/bhk3)

It's probably just a few lines to restore the database session the right way... Would need to look deeper at the mechanics in https://github.com/pallets-eco/flask-sqlalchemy and reproduce what they do there to re-init the sesh

@mistercrunch mistercrunch marked this pull request as draft December 5, 2024 01:39
@@ -101,6 +102,7 @@ def execute(
raise
except Exception as ex:
logger.exception("Query %i failed unexpectedly", query_id)
logger.error(ex)
Copy link
Member

Choose a reason for hiding this comment

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

Is this to get some message from the exception logged?

Copy link
Member

Choose a reason for hiding this comment

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

logger.exception already logs the exception, in addition to the message, it's what differentiates it from logger.error. So this line is not needed.

@@ -101,6 +102,7 @@ def execute(
raise
except Exception as ex:
logger.exception("Query %i failed unexpectedly", query_id)
logger.error(ex)
Copy link
Member

Choose a reason for hiding this comment

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

logger.exception already logs the exception, in addition to the message, it's what differentiates it from logger.error. So this line is not needed.

is_feature_enabled("DISABLE_METADATA_DB_DURING_ANALYTICS")
and pool_type == "NullPool"
)
conn = db.session.connection()
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? This is just a new connection, it seems like creating it here, closing it in the try and reopening it in the finally will do nothing.

@mistercrunch
Copy link
Member Author

made the changes, closing in favor of apache#31315

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants