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

Missing Primary Key screws up DB Replication #2142

Closed
roha4000 opened this issue Mar 6, 2013 · 8 comments
Closed

Missing Primary Key screws up DB Replication #2142

roha4000 opened this issue Mar 6, 2013 · 8 comments

Comments

@roha4000
Copy link

roha4000 commented Mar 6, 2013

Hi,

We are using a Galera cluster as a MySQL-DB backend. Within the db_structure.xml there are three tables without a Primary Key defined which leads to replication failures within the db cluster. This should also affect normal Master - Slave replication scenarios.

tables missing a Key:

group_user
group_admin
properties

As far as I can say those tables are a good candidate for an auto_increment field 'id', aren't they?

best regards
Roland Hager

@BernhardPosselt
Copy link
Contributor

@blizzz @icewind1991

@BernhardPosselt
Copy link
Contributor

Adding it will cause a ton of breakage. Not sure how this fix should be done.

@roha4000
Copy link
Author

I actually added an auto_increment field "id" and had no breakage using MySQL. Other databases, which are adding automatically primary keys when the are missing might be more affected. BUT: Shouldn't a primary key be obligatory?

btw. the properties table is really under frequent access. We already have more than 300k entries in our test environment and not using an index results in a lot of full table scans. Setting an index reduced the number of accessed rows from 201.009 to 54.412 and the execution time from 0.16s to 0.07s when "explaining" on of the worse selects. The index is at about 12% of the size of the whole table.

mysql> create index userid_index ON oc_properties (userid);

@BernhardPosselt
Copy link
Contributor

see #2191

@BernhardPosselt
Copy link
Contributor

Ok, seems to be a very serious issue since there is not a single! field with primary key. I'll be asking on the mailing list if this is fixable in any way that doesnt make upgrading impossible.

@tanghus
Copy link
Contributor

tanghus commented Mar 18, 2013

seems to be a very serious issue since there is not a single! field with primary key.

Most tables have primary keys from the autoincrement field, so afaik it is only the three tables mentioned above.

@BernhardPosselt
Copy link
Contributor

tables that dont have a primary key (and neither auto increment):

  • appconfig
  • file_map
  • files_trash
  • files_trashsize
  • files_versions
  • group_admin
  • group_user
  • groups
  • permissions
  • preferences
  • properties
  • users
  • category_to_object

by using sqliteman

@tanghus
Copy link
Contributor

tanghus commented Mar 18, 2013

  • appconfig

Could make appconfig_appid_key_index unique and primary

  • filemap

Could set file_map_lp_index as primary

groups

has groups_pKey as primary

permissions

Could use id_user_index

preferences

Could use pref_userid_appid_key_index

users

Defines a primary key on users_pKey

  • category_to_object

Defines a primary key on category_object_index.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants