ergo / ziggurat_foundations

Framework agnostic set of sqlalchemy classes that make building applications that require permissions an easy task.
BSD 3-Clause "New" or "Revised" License
71 stars 22 forks source link

Resource not found on delete branch with tree service #63

Closed fmigneault closed 5 years ago

fmigneault commented 5 years ago

Using resource_tree_service = ResourceTreeService(ResourceTreeServicePostgreSQL), I call resource_tree_service.delete_branch(resource_id=resource.resource_id, db_session=request.db), which causes a resource to not be found after in passes: https://github.com/ergo/ziggurat_foundations/blob/5a40c721e59b6cecfa6e1bd5fbb2d369dc12398e/ziggurat_foundations/models/services/resource_tree_postgres.py#L72-L74

If I use list(query.filter(cls.model.resource_id == resource_id)) instead WITHOUT the with_for_update() call, the resource is correctly retrieved. With it, it returns None. Any idea why I might be getting this behavior suddenly? I have been using the same method resource_tree_service.delete_branch(...) for as long as I can remember and resources where properly removed.

ergo commented 5 years ago

Hello,

I don't think I've made any changes to tree service in last months. And my tests pass as far as I can tell, can you prepare a minimal test case to reproduce this?

fmigneault commented 5 years ago

It's ok, I was just wondering if you had experienced this before. It seems some entries of my db got corrupted somehow, I don't even know how to reproduce. I have wiped some tables and tried again, and all is working fine as before...