0

I have a linked table id_group | id_user. Every time I add a one or more users to a group I DELETE all the links and INSERT the users again including the new one(s). This is how the framework of the application works.

From time to time some groups lose all the users they had, except the new ones, which are inserted.

The primary index of the table is the pair id_group - id_user.

I cannot reproduce this through a query, but the client has complained multiple times and there's an issue no doubt.

I could explain this if the table was innoDB with the DELETE locking the index and the INSERT not being able to add that pair again, however this is a myISAM table and myISAM locks the entire table during DELETE statements.

2
  • Can you provide the exact DELETE query you use? Commented Oct 5, 2012 at 13:07
  • DELETE from users-user_groups where id_group = x Commented Oct 15, 2012 at 13:28

1 Answer 1

2

Is it possible you've got two processes attempting to do this at almost the same time? If this is a web application, could you have a site user who is double-click happy?

Process #1 "examine existing users"
Process #1 "remove all users"
Process #2 "examine existing users" (no users would found)
Process #1 "insert new users and put existing users back"
Process #2 "remove all users"
Process #2 "insert new users and put existing users back (but no existing users were found)"
2
  • This happens automatically, not as a direct user action. A user (or more) is assigned to a group, an object with all the users (old and new) is created, the links from the table are deleted for that user group, the object is parsed and the inserts are made. Commented Oct 15, 2012 at 13:31
  • 1
    but what is the process that a user assigned to a group? Commented Oct 15, 2012 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.