Project

General

Profile

Actions

Task #101425

closed

TYPO3 and MariaDB Galera Cluster (PRIMARY KEY)

Added by Ralph Brugger 10 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
System/Bootstrap/Configuration
Target version:
-
Start date:
2023-07-24
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.1
Tags:
Complexity:
easy
Sprint Focus:

Description

In the Known Limitations of the MariaDB Galera Cluster you can read:
https://mariadb.com/kb/en/mariadb-galera-cluster-known-limitations/

All tables should have a primary key (multi-column primary keys are supported). 
DELETE operations are unsupported on tables without a primary key. 
Also, rows in tables without a primary key may appear in a different order on different nodes.

In our project we have a lot mm-tables that don't have a primary key:

TYPO3:
sys_category_record_mm

EXTENSIONS:
tx_rsmevents_event_category_mm
...

For TYPO3 it's normal to NOT have a primary key on MM-Tables:
https://docs.typo3.org/m/typo3/reference-tca/11.5/en-us/ColumnsConfig/CommonProperties/Mm.html#tca-property-mm

If you have a look at the LogWriter-Docu there is a hint about Galera:
https://docs.typo3.org/m/typo3/reference-coreapi/11.5/en-us/ApiOverview/Logging/Writers/Index.html

If you are using a MariaDB Galera Cluster you should definitely add a primary key 
field to the database definition, since it is required by Galera 
(this can be a normal uid autoincrement field as known from other tables): 
MariaDB Galera Cluster - Known Limitations.

So what for the mm-tables?

We could add:
a) an uid field with auto_increment and PRIMARY KEY

CREATE TABLE anytable_MM (
    uid int(11) NOT NULL auto_increment,
..
    PRIMARY KEY (uid),
);

b) or add an multi-column primary key on uid_local uid_foreign - I'm not sure if this is possible, or there can de duplicates.

CREATE TABLE anytable_MM (
  uid_local int(11) DEFAULT '0' NOT NULL,
  uid_foreign int(11) DEFAULT '0' NOT NULL,
  ...
  PRIMARY KEY (uid_local,uid_foreign),
);

I think the combination of uid_local and uid_foreign could or should be unique.
But I'm not sure, so solution a) should be the better solution.

Ralph


Related issues 7 (1 open6 closed)

Related to TYPO3 Core - Feature #95061: Auto creation of MM tables from TCAClosed2021-08-31

Actions
Related to TYPO3 Core - Task #101528: Fix MM TCA of blog_exampleClosed2023-08-02

Actions
Related to TYPO3 Core - Task #101537: Have correct blog_example related_posts TCAClosed2023-08-02

Actions
Related to TYPO3 Core - Task #101554: Get rid of MM_hasUidFieldClosed2023-08-03

Actions
Related to TYPO3 Core - Bug #101720: sys_category_mm does not have a unique keyClosed2023-08-21

Actions
Related to TYPO3 Core - Task #101731: Adjust auto-created column length for MM tablesClosedStefan Bürk2023-08-22

Actions
Related to TYPO3 Core - Bug #103604: MM table generation sets wrong PRIMARY KEY for columns with multiple=1Needs Feedback2024-04-11

Actions
Actions

Also available in: Atom PDF