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

[POC/RFC] Operations queue #396

Open
wants to merge 4 commits into
base: 2.x
Choose a base branch
from

Conversation

dantleech
Copy link
Contributor

This is an experiment for an operations queue which unities the seperate scheduledInserts, scheduledUpdates, scheduledReorders, etc. into a single queue.

This enables persistance operations to be committed out in the order in which they were programmed.

This makes sense for move, reorder and delete operations which can have multiple entries in the stack for a given document. It makes less sense for "update" because the changeset is not recorded for each operation ("persist") but is calculated once before comitting.

Lots of test fails here and this is not necessarily the solution we need, just an experiment.

@dbu
Copy link
Member

dbu commented Dec 25, 2013

wow, quite a rewrite. imo it makes sense to attempt this, its the natural way. you can also look at the code in jackalope to get inspired, we have a quite similar approach in the jackalope unit of work (called ObjectManager there).

note that add and remove can happen through modified child fields and children collections, and move through assignment. all of those will only be detected at flush time. but i would say that is live and if you do stuff where the order matters, with these changes you at least stand a chance to do things.

benjamin told me that for the ORM, they have something that calculates the transitions needed to get from the persisted state to the current memory state (in terms of what needs to be done first and after that and so on). this would work even for the implicit add/remove/move operations and be exactly in the declarative spirit of doctrine. but i imagine it could be quite hard to calculate.

@dantleech
Copy link
Contributor Author

In regard to implicitly calculating the changes, the use case that breaks the current system is:

move: /foobar > /barfoo
create: /foobar

Create is done before move, so it doesn't work. We could add some sepcial code to detect this. The question I am asking myself is if there are other scenarios where the order of operations might matter. - and to what extent recording the order of events is important.

The operations queue is a much more intuitive and natural way to process the commit, and so it should be easier to maintain and have less bugs. Performance I guess depends on the size of the queue and on any compression we can apply to the queue before flushing. I don't know if it would be inherently slower than the implicit method, but after optimization it should be negligible one way or the other.

Just musing.

@dbu
Copy link
Member

dbu commented Feb 1, 2014

i think the idea of leveraging ocramius/changeset is interesting here. we would record changes as we notice them, but for the implicit changes (adding a child, renaming something and so on) calculated in the uow its gonna be more or less undetermined, but for all explicit calls at least the order would be preserved. this has potential for quite some BC breaks - we should make sure to calculate in the order that we previously had, to minimize them.

@dantleech
Copy link
Contributor Author

I understand it as we only need an operation queue for tree operations (move, delete, create, reorder, etc). The documents and their data would be handled by the changeset. So first you would run-off the operation queue, then you would apply the changeset -- having mandatory UUIDs will be of great use here.

Shall we schedule this for 2.0? Without mandatory UUIDs this would be more tricky I think, and as you mention there will be BC breaks.

@dbu
Copy link
Member

dbu commented Mar 14, 2015

this sounds a lot like 2.0 to me, yes.

you are right about field changes. but there are quite some tricky things to keep in mind (field changes on moved documents and detect that we don't need the changes on a deleted document, for example)

@dantleech
Copy link
Contributor Author

Really need to have another crack at this. Maybe there is away that doesn't involve rewriting the UOW.

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

Successfully merging this pull request may close these issues.

2 participants