[development] CCK and Node Access Duplicate Insert errors
Blaine Lang
Blaine.Lang at nextide.ca
Tue Apr 19 14:36:07 UTC 2011
Regarding these duplicate entry records issue: I believe this is a race
condition and is very similar to this core issue:
http://drupal.org/node/230029
The issue for me is very easy to duplicate when uploading 3 or more
files at one time - when the node_save is executed. Given that I'm
surprised this issue with CCK has not surfaced before and there may very
well be an issue on this already but I was not able to find it.
Duplicate entry '16-0-all' for key 1 query: INSERT INTO node_access
(nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (16,
'all';, 0, 1, 0, 0)
Duplicate entry '16-1' for key 1 query: INSERT INTO
content_field_filedepot_file (vid, nid, delta, field_filedepot_file_fid,
field_filedepot_file_list, field_filedepot_file_data) VALUES (16, 16, 1,
234, NULL, NULL)
Following the ideas posted in issue 230029, I added the call to
db_lock_table() around the node_save()
db_lock_table($content_type['tables']['content_field_filedepot_file']);
node_save($node);
db_unlock_tables();
Now that solved my duplicate_insert issue and confirms (I believe) this
is a race condition issue. BUT ... now I get about 10 warnings from
other tables when the db_unlock_tables is called since they are not
locked as in:
user warning: Table 'node' was not locked with LOCK TABLES query: UPDATE
node SET vid = 8, type = 'filedepot_folder', language = '', title =
'X1.2', uid = 1, status = 1, created = 1303222742, changed = 1303222771,
comment = 0, promote = 0, moderate = 0, sticky = 0, tnid = 0, translate
= 0 WHERE nid = 8 in F:\web4\nexdrupal\includes\common.inc on line 3538.
There is not optional parameter to pass to db_unlock_tables - it's an
all or nothing.
This would appear to be a core or CCK issue - is anyone aware or can
confirm my findings. Is there a known issue or work around?
My backup option is to add my own queue logic to handle these inserts.
More information about the development
mailing list