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

Check ObjectDeletedError catching on delete #400

Open
Glutexo opened this issue Aug 15, 2019 · 3 comments
Open

Check ObjectDeletedError catching on delete #400

Glutexo opened this issue Aug 15, 2019 · 3 comments

Comments

@Glutexo
Copy link
Collaborator

Glutexo commented Aug 15, 2019

This looks like a possible bug, but maybe it isn’t. It’d be good to verify and comment.

When deleting a Host, it can happen, that a host has been already deleted by a different request before iteration finishes. I am not sure, whether the sqlalchemy.orm.exc.ObjectDeletedError is actually raised when the id property is accessed or when iterating. The latter looks more probable to me, but I don’t know the internal workings of SQLAlchemy.

It’s also possible that #392 will cause that the exception is never raised, because the property is no longer going to be accessed. Also I am not sure, what the synchronize_session="fetch" argument for the delete does and why there is an explicit DB commit.

All this should be properly commented and for that it’s necessary to research and verify the actual workings. Such a complex functionality also has to be covered by tests, although here multiprocessing is required and such test is going to be non-trivial.

@aleccohan
Copy link
Collaborator

It seems as though I was mistaken about my previous comment on this issue. Through alot more testing I have found that without the changes made in PR #392 the ObjectDeletedError is not catching at all. In fact it continues to run even though the host has been deleted as if nothing happened at all.

@Glutexo
Copy link
Collaborator Author

Glutexo commented Aug 21, 2019

Oh, so my original fear was correct. That‘s a bit sad, because it’s necessary to fix that so the error is correctly caught. But I’m glad you found it!

@aleccohan
Copy link
Collaborator

Yeah me too! I was wondering why the test I was writing wasn't working so I decided to give it another look and it turns out your original idea was absolutely right.

I'm curious why the catch works with #392, I think you were absolutely right about that one as well with the accessing of the host during the printing of the deletion event.

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

No branches or pull requests

2 participants