-
Notifications
You must be signed in to change notification settings - Fork 33
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
Migrates tree_id from an Integer
to Unicode(32)
#53
base: master
Are you sure you want to change the base?
Conversation
…to a Unicode(32) so that tree IDs can be generated as GUIDs in application code and be thread safe.
…g they're incremental integers.
…en moved resolved the incongruous tree_ids.
Integer
to Unicode(32)
@markroper Thank you for your interest in the library.
If we choose the UUID4 it will take up more space (32-4=28bytes per row) in the database and not allow trees to keep order. I think that is wrong. I think it is possible figure out how to make this field is re-defined for more flixibility of this lib. On the other hand, but is it necessary? |
@uralbash Thanks for the reply! In the use case I have, I do not care about the ordering of the different trees and so maintaining an integer tree id is not a requirement. I understand that you've supported it here as part of the port. Your point about the additional space required for a UUID is a good one, but for my use case, the additional size is not a concern. The issue I see is on https://github.com/uralbash/sqlalchemy_mptt/blob/master/sqlalchemy_mptt/events.py#L77 |
I would like to save the sort feature because I use it in |
The select for update query will lock for the duration of that select query, but will not lock after that, so I don't think it would eliminate this vulnerability. I think if you want to support this you'll need to create a table in the database that has an auto-incrementing PK. Instead of generating the new PK with If you did this, you could still maintain integer-based tree_ids and eliminate the multithreading bug. |
Items that must be completed:
|
The
tree_id
column is currently an Integer thats managed in application code. New trees are created by querying for the max value in the table and incrementing it by one, which isn't thread safe. An an example, a multithreaded application may try to create two different new trees and assign them both the same tree_id. I've made the tree_id aUnicode(32)
so that tree IDs can be generated as GUIDs in application code without the risk of ID collisions.I like the lib a lot!