Closed (fixed)
Project:
Universally Unique IDentifier
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Sep 2010 at 22:31 UTC
Updated:
25 Oct 2010 at 17:40 UTC
Jump to comment: Most recent file
Comments
Comment #1
apotek commentedConfirmed: When deleting all revisions, the 'delete revision' sequence never gets called in uuid_nodeapi()
Comment #2
apotek commentedThe solution for how to deal with deletion of all node_revision uuids upon deleting a node will be complicated.
During the 'delete' part of the nodeapi, by the time we get to uuid, the revisions are already gone from the $node object, so there's no query we can build to find out an array of revision ids that we need to scan uuid_node_revision for.
The only $node properties of any interest to us that are set are:
["vid"]=>
string(2) "15"
["current_revision_id"]=>
string(2) "15"
["num_revisions"]=>
string(1) "2"
This information allows us to *at least* delete the latest revision uuid for the node, but we also see that there are 2 revisions, and they both need to be deleted. However, the node does not have any array of revision ids attached to it. further, as stated above, the rows are already gone from the node_revision table, so we can't query for them.
A quick improvement would be at the very least to add to the nodeapi 'delete' sequence a call to DELETE the last known revision. That would take care of the vast majority of cases.
The *right* fix for this is to ask why 'delete revision' isn't being fired by nodeapi before the 'delete' sequence is activated. But this adds expense to nodeapi.
Without waiting for fixes from on-high in this case, we are probably better off modifying the uuid_node_revision table by including the nid as a non-unique, non-indexed column in the table. No index: speeds things up, and we *only* ever scan for nid values on delete, so let's keep loads lean and mean by leaving indexes only on the other two columns.
Modify the queries which write data to the uuid_node_revision table to take account of the schema changes.
Modify the uuid.install file to account for the changes as well.
This way we can *guarantee* we can delete all the revision uuids for a node regardless of the various lacunae in the nodeapi implementation.
Comment #3
apotek commentedA fix for this is in the patch on this thread: http://drupal.org/node/918888
Requires mods to uuid.install and the underlying schema, also detailed in the patch.
Comment #4
apotek commentedHere's a patch that sets up the schema and modifies the relevant queries such that uuid_node_revisions rows can be deleted on a node delete action.
I created the patch against uuid-DRUPAL-6--1 HEAD.
Comment #5
apotek commentedComment #6
apotek commentedAny input on this fix for this bug from anyone?
Comment #7
recidive commentedPatch looks good.
There are just code style issues with code comments, if you don't mind fixing them.
I hope to review this more thoroughly late this week.
Thanks!
Comment #8
apotek commentedEdited my comments and rolled a new patch against latest in CVS DRUPAL-6--1.
Comment #9
apotek commentedAre the code styling issues resolved with the new patch?
Any other thoughts on this? Anything blocking this? Would love to put this to bed so I can roll out new patches with this in place.
Comment #10
recidive commentedI went ahead and reviewed the patch more deeply. Here are some issues I've found with it:
1. Since uuid_node_revisions_table_schema() generate table schema exclusively to node revisions, is there really a need for the $key argument? Will not it be always set to 'vid'? Also, can't we move the logic in uuid_node_revisions_table_schema() to hook_schema(). I'm not seeing much benefit from this being a separate function.
2. It doesn't make sense changing uuid_update_6003() function, instead you should implement uuid_update_6004() and add your changes to database there.
3. There are still some codestyle issues with inline comments. They should start with a space, capital letter and end with a period, they also need to wrap at 80 chars.
4. Can you explain the need for the $active_only parameter added to node_get_by_revision_uuid()?
Thank you!
Comment #11
apotek commentedOk. Integrated it all into uuid_schema.
Done. Although, of course, this will conflict with the other patches in which I'm also writing a _6004 function.
Never read about the 80 char requirement before, and it was not caught by the coder module. I have changed my page guide to 80 chars from 72, and changed the comment lengths.
I wrote the following in a comment above that function:
* @todo One thing to ascertain here is whether this function
* should only return the node if the revision's uuid is the
* active revision for that node, or if it should also return
* the node even if the revision is not the active one. We
* make active-only the default implementation for now, just
* to be on the safe side.
So basically, I added that parameter as a future-oriented parameter, whereby which the function *could* support returning the node even if the revision passed is not the active revision. Right now, it can only return the node if the passed revision uuid is the current revision.
The "else" part of the function supported returning a node even if the revision uuid passed was NOT active, if a person were to also pass the $active_only as FALSE.
However, since there is no part of the code that relies on this, I have ripped it out of the current function.
I do think, however, that it should be discussed whether inactive revision uuids should be supported. Any such discussion would, of course, require the implementation of this patch first, since the nid column in the uuid_node_revisions table is necessary.
Comment #12
apotek commentedComment #13
apmsooner commentedI think my error is related:
user warning: Duplicate entry '727' for key 'PRIMARY' query: INSERT INTO uuid_node_revisions (vid, uuid) VALUES (727, '1b969aec-d19b-11df-be90-002219221c49') in /home/autop5/public_html/webmanager/sites/all/modules/uuid/uuid.module on line 70.
Interestingly, Its when editing a node that doesn't have automatic uuid generation set and where node revisions are turned off. If node revisions are turned on, I don't get the error. Should I enable node revisions for the time being on all my content types just to get rid of the error or is there a fix on the way soon?
Comment #14
apmsooner commentedFYI, I would just enable node revisions to solve the issue I'm having but I'm having the error occur on node creation as well which really kills it for me to even use the module as it stands. Any ideas around this?
Comment #15
apotek commentedany thoughts from anyone?
Comment #16
apmsooner commentedI looked at the table and upon creating a new record theres nid:727 vid:733 and in the uuid node revisions table there is vid:733 and uuid:29182ff6-d19f-11df-be90-002219221c49
so.. it appears vid is clashing upon node creation. Enabling node revisions doesn't do anything for me because the node hasn't been created yet to even have an existing vid. I guess its an order of operations issue where the vid and uuid gets assigned.
Comment #17
apotek commented@apmspooner. The behavior you are mentioning has nothing to do with what this patch is for. This patch is meant to address the fact that when a node is deleted, or all revisions are deleted (same thing), the node_revisions table keeps all the old vid<>uuid relationships, now orphaned and useless.
What you are writing about is a completely separate issue.
This thread is about the fact that uuid module has a bug that causes node_revisions table to never get cleaned out.
Comment #18
recidive commented@apmsooner: are you getting this problem even with 6.x-1.x-dev version?
I think the problem you're getting got fixed in #895622: user warning: Duplicate entry in uuid_node_revisions, but it hasn't been pushed to a beta release yet.
If you are still getting this kind of problems with 6.x-1.x-dev version, please re-open the above issue.
Thanks!
Comment #19
apmsooner commentedyes, happening on stable and latest dev versions. I just ran an update with the dev release so I will try uninstalling and then reinstall to see if anything different. I hope it is fixed because i would assume everyone would be seeing this issue otherwise when simply creating a new node. Crossing my fingers... I'll post back shortly with results.
Comment #20
apmsooner commentedOkay I installed dev version on completely different site and bug is still happening. It doesn't happen every time i save a node though. I've created 3 new blog entries, no error and then on the 4th one i got an error. Same thing with editing and saving, sometimes the error pops up and sometimes not. Since I'm being told this is a different issue, I will post it separately and link back to this one.
FYI @klktrk, this issue is not related to the deletion of nodes at all. I only edited existing nodes or created new ones and the error pops up. No nodes were deleted in the process of my testing.
Comment #21
apotek commentedEXACTLY, so why are you posting your comments on your issue in the wrong thread? Please don't hijack another issue. (Please take a look at some of the discussion here http://drupal.org/node/895622 and here http://drupal.org/node/918888. There is a fundamental misconception on the part of the uuid developers when it comes to updates to a node with revisions. A good workaround patch was written and comitted, but it's not the real solution, as the real conceptual work behind the idea of updating a revision has not been worked out.)
Now, can we get back to the topic at hand? I take it everyone is content to leave this glaring bug in the uuid module? Nobody is bothered by the fact that entries in the uuid_node_revisions table don't get deleted? Or am I simply the only person who has ever looked at the contents of that table? :-)
Comment #22
apmsooner commentedMy issue appears to be completely different from the existing ones which is why I created a new issue. I only figured that out from deductive reasoning in reading through the posts you referenced so not sure what the problem with that is. I don't care either about entries in a table not being deleted but I do care about a glaring error on the screen when creating or editing a node and I would think others do too. Anyhow, enough said... the issue remains as posted so feel free to ignore if you so choose. Thanks.
Comment #23
markdorisonThe patch in #11 looks good. Anyone see any issues?
Comment #24
recidive commentedOk, I've changed the uuid_update_6004() to uuid_update_6005() and committed the patch in #11.
Thanks!
Comment #25
recidive commentedSorry @apotek, your name was not pasted correctly in the commit message.
Thank you for working on this!
Comment #26
apotek commentedThanks @recidive. Glad to see it checked in. It was a fairly far-reaching patch, touching a lot of different lines of code, so this helps a lot. No worries about the commit message.
Comment #27
apmsooner commentedForgive my ignorance if I'm dead wrong on this but shouldn't the UUID be the primary key in the uuid_node and uuid_node_revisions tables? As it stands nid is primary in uuid_node and vid is primary in uuid_node_revisions which I think is whats causing my bug on node creation/edit:
user warning: Duplicate entry '766' for key 'PRIMARY' query: INSERT INTO uuid_node_revisions (vid, uuid, nid) VALUES (766, '75c9fdfc-d55a-11df-be90-002219221c49', 752) in /home/autop5/public_html/webmanager/sites/all/modules/uuid/uuid.module on line 72.
My assumption could be completely wrong but in looking at the table structure in the location module, the lid is the primary key in the location table and relates to another table that contains nid, vid and so on. Shouldn't the UUID tables be setup in the same manner to prevent this error from happening?
Comment #28
apotek commented@apmsooner: You may want to add a new issue for this. The reason the current uuid_node.nid and uuid_node_revisions.vid fields are primary is that those are the fields used in the lookups in queries, not the uuid fields. While on a pure theory level, perhaps there are other fields that should be primary, if you look through the selects and joins in the uuid module, you'll see .vid and .nid referenced and used for almost all lookups. That's why they're primary, and not some other field.
If you still disagree, please feel free to open a new issue and discuss it there.
This has nothing to do with this patch. You yourself have opened a ticket to address it elsewhere: http://drupal.org/node/934142
Thanks for your reply.