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

Question - children_count = -1 #521

Open
stevieing opened this issue Dec 9, 2020 · 2 comments
Open

Question - children_count = -1 #521

stevieing opened this issue Dec 9, 2020 · 2 comments

Comments

@stevieing
Copy link

Thanks for the gem. We have been using it for a while now successfully.

I am asking this as a question as I am not sure if this is a bug, known issue or application dependent and how to test it.

During the past nine months usage of our application has exploded and recently we have had reports of records with a children_count of -1.

I originally disputed that this was an issue at all but have found a couple today. I have a few strategies for mitigation but was wondering if this was something that people have encountered and if so what they did about it?

The users are visiting a page within our application to remove all of the child records at once and there is a method to do that.

If I do discover it as a bug with the gem I will happily open an issue with tests etc.

Looking through the repo I have noticed a few comments with regard to changes made in Rails 6. Would it be worth upgrading to Rails 6 first (we are running 5.2)?

Thanks in advance.

@kbrock
Copy link
Collaborator

kbrock commented Dec 9, 2020

Hello @stevieing

I haven't seen the children_count issue you speak, but I tend not to use the cached columns.
But I can see how a counter could get off by one, especially in the rails space.

It may have something to do with deleting all records or the parent caching the value. I think I imagine the value being too big rather than too small, but fixing one may fix the other. Maybe it is deleting one while it is deleting all in a separate thread?

Rails 6 has changed the way that scopes are implemented, removing "leaky scopes" so that has thrown ancestry for a little spin. It will not be a problem until 6.1 but in the mean time, a number of deprecation warnings come to play.

Most (or all) deprecation messages are presented with model.children.create. To be picky, children is a scope and not a relation, so it complains that it will not work in 6.1. I'm making some significant changes to try and make it more rails 6.1 friendly and hopefully making it more sql friendly at the same time. Changes like these are non-trivial and have not been a priority since we are also in the process of upgrading to rails 6.0.

I would upgrade ancestry before upgrading to rails 6.0. The latest is backwards compatible and works better in the rails 6.0 world. But I tend to want to upgrade as much as possible before making the switch - which I guess has the potential to draw out the transition/upgrade process.

@stevieing
Copy link
Author

Hello @kbrock

Thanks for the prompt reply. I have a few things I can try. Thankfully it is not a data integrity issue but is causing a bit of nervousness amongst our customers.

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