-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
[4.1.0rc2] sqlalchemy InvalidRequestError: This nested transaction is inactive when trying to activate embedding on a dashboard #30216
Comments
Hello @ablanchard! I'm here to assist you with any bugs, questions, or contributions related to Superset. Let's dive in and tackle this issue together! The error "sqlalchemy InvalidRequestError: This nested transaction is inactive" occurs when trying to activate embedding on a dashboard in Superset 4.1.0rc2 because the nested transaction is being used incorrectly or has already been rolled back or committed. In the provided code, the issue likely arises from the following block: with db.session.begin_nested():
embedded = EmbeddedDashboardDAO.upsert(
dashboard,
body["allowed_domains"],
) If an exception occurs within the To handle this properly, ensure that the nested transaction is correctly managed and that any exceptions are handled appropriately to avoid leaving the transaction in an inactive state. Here is an example of how you might handle this: try:
with db.session.begin_nested():
embedded = EmbeddedDashboardDAO.upsert(
dashboard,
body["allowed_domains"],
)
result = self.embedded_response_schema.dump(embedded)
return self.response(200, result=result)
except ValidationError as error:
return self.response_400(message=error.messages)
except Exception as e:
db.session.rollback() # Rollback the session to avoid inactive transaction
logger.error("Error during embedding activation: %s", str(e))
return self.response_500(message="An error occurred while activating embedding.") This ensures that if an exception occurs, the session is rolled back, preventing the nested transaction from becoming inactive [1]. |
@ablanchard Did you ever get this resolved? |
@mujibishola No. I have tried to reproduce in docker but without success. |
@ablanchard you mean you're unable to reproduce the bug in docker, so we're all good? Or you're unable to resolve the error? Not sure if you or anyone are seeing this as a 4.1 blocker... CC @sadpandajoe as release manager and @michael-s-molina as a reviewer of the linked PR, in case either of them want to track this further. |
@rusackas On my kubernetes deployed instance I have the stacktrace. When I do the same on a docker instance, I don't have the stacktrace. Giving the stacktrace, is there anything I can do in the step to reproduce, to be sure to have the stacktrace also on the docker one ? |
LocationFile: IssueThe current implementation is failing to save embedded dashboards properly. FixReplace the following code: try:
body = self.embedded_config_schema.load(request.json)
with db.session.begin_nested():
embedded = EmbeddedDashboardDAO.upsert(
dashboard,
body["allowed_domains"],
)
result = self.embedded_response_schema.dump(embedded)
return self.response(200, result=result)
except ValidationError as error:
return self.response_400(message=error.messages) With this updated version: try:
body = self.embedded_config_schema.load(request.json)
embedded = EmbeddedDashboardDAO.upsert(dashboard, body["allowed_domains"])
result = self.embedded_response_schema.dump(embedded)
return self.response(200, result=result)
except ValidationError as error:
return self.response_400(message=error.messages) Changes
RationaleThe nested transaction was interfering with the saving process of embedded dashboards. Removing it allows the save operation to complete successfully. |
@mujibishola Hello, seems to fix my problem. You will make a PR with this changes, this way I can deploy it on my test environment. I can also make the PR if you want |
i am facing the same issue. is there a way to fix it manually on k8 setup? can not modify the code and using the pre release images from this repo. |
Bug description
On a fresh install of superset 4.1.0rc2, I have imported dashboards from my 4.0.2 instance and I try to activate the embedding feature on it.
No matter if I do it via api or via the UI, every time I end up with the stack:
To note: I'm activating the embedding without giving a domain.
I have tried reproducing the error on a docker instance in 4.1.0rc2 but I haven't succeeded. I have try with both the examples dashboards and imported ones.
I saw that the code changed recently in this PR
Do you have any clue why this behavior can happen ?
How to reproduce the bug
Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Firefox
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: