I have a strange problem that I cannot figure out.
I have a database model that looks like this:
The A object is shared private in the org. User A creates record 1 and will become the automatically be owner of it. The "User" field will be set to User A. There is APEX sharing giving User B (user A's manager) read/write access to the object.
Both User A and User B is on the same profile and role and the profile has access to create, edit, update and delete to both object A and B (not "all"). When I look at the sharing records for record 1 I can see a R/W sharing rule for User B.
When logging in as User B I can edit record 1 without any problems. But when I try to delete it I get an permissions related error that I cannot explain.
First exception on row 0 with id XXXXXXXXXXXXXXXXXX; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: 
(I've replaced the ID with X:es).
Any ideas what could cause this?
I am suspecting that Salesforce is removing the sharing in the delete process but cannot find any information about.