sehughes / django-treebeard

Automatically exported from code.google.com/p/django-treebeard
Apache License 2.0
0 stars 0 forks source link

Integrity issue #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is what I get on the console:

In [47]: ContentNode.find_problems()
Out[47]: ([], [], [])

In [48]: kat.numchild
Out[48]: 1

In [49]: kat.get_children()
Out[49]: []

I'm wondering if it's OK when a node has numchild=1 but get_children returns 
nothing? Also, 
shouldn't find_problems detect this?

Original issue reported on code.google.com by eallik on 26 May 2009 at 5:38

GoogleCodeExporter commented 9 years ago
eallik:

Please remember that kat is a cached copy of the object in memory, it's not 
what you have in the database. 
Please retreieve kat again (with ContentNode.objects.get()) after calling 
find_problems().

Let me know if the problem persist.

Original comment by gpicon on 14 Jun 2009 at 12:31

GoogleCodeExporter commented 9 years ago
My point was something else: I was saying that even though I have an 
inconsistency in the tree, find_problems 
doesn't find it. It's not about ORM objects and DB being out of sync even 
though it might have looked like it.

If I check the database table itself, it clearly shows the row as having 
numchild=1 but no actual children. I had 
this with several nodes. I'm just saying find_problems should detect it.

Original comment by eallik on 14 Jun 2009 at 2:05

GoogleCodeExporter commented 9 years ago
eallik:

That's 2 bugs then:

1) treebeard is corrupting the tree (unless you're accessing the table 
directly? maybe django admin?)
2) find_problems can't, well, find this problem :)

What Tree backend are you using btw? (MP/NS/AL) Is it sorted?

Original comment by gpicon on 14 Jun 2009 at 2:59

GoogleCodeExporter commented 9 years ago
MP and unsorted. I'm using transaction middleware, too, so I guess that means 
it's not my fault it got 
corrupted...?

Original comment by eallik on 14 Jun 2009 at 3:02

GoogleCodeExporter commented 9 years ago
eallik:

Sounds like a bug in treebeard then. Just curious: did you define Meta in your 
subclass? Take a look at issue 5 ( 
http://code.google.com/p/django-treebeard/issues/detail?id=5 ) for reference. 
If you didn't, then this looks like 
a TB bug. Can you easily reproduce it?

Original comment by gpicon on 14 Jun 2009 at 3:22

GoogleCodeExporter commented 9 years ago
I have meta with ordering = ('path', ) defined. About reproduction - if you 
mean 1) treebeard is corrupting the 
tree, then no - I'm not aware of when the corruption was introduced. I've set 
up a 
TreeIntegrityValidationMiddleware to call find_problems before transactions are 
committed to check for any 
introduced inconsistencies, but obviously since find_problems doesn't find this 
problem, the middleware didn't 
report any problems.

Original comment by eallik on 14 Jun 2009 at 3:38

GoogleCodeExporter commented 9 years ago
eallik:

I added 2 new checks for MP_Node.find_problems() in r98
http://code.google.com/p/django-treebeard/source/detail?r=98

Should help your custom midleware :)

(note: you need to checkout trunk to try it)

Original comment by gpicon on 14 Jun 2009 at 4:21

GoogleCodeExporter commented 9 years ago
eallik:

From r99:

Added a new (safer and faster but less comprehensive) MP_Node.fix_tree() 
approach.

Calling MyMPNodeClass.fix_tree(False) should fix your numchild inconsistencies.

Please let me know if your tree breaks again. Should be easy to catch with your 
middleware.

Thanks!

Original comment by gpicon on 14 Jun 2009 at 7:28

GoogleCodeExporter commented 9 years ago
No more problem reports... I'm assuming the problem was solved by r99

Original comment by gpicon on 4 Oct 2009 at 1:20

GoogleCodeExporter commented 9 years ago
Actually I haven't had time to investigate this issue further. But I'll let you 
know when it occurs again.

Original comment by eallik on 4 Oct 2009 at 10:40

GoogleCodeExporter commented 9 years ago
Thanks eallik, please reopen this ticket if needed :)

Original comment by gpicon on 4 Oct 2009 at 3:55