Create empty tables- Recovering from table corruption oc_reactions and oc_tables_views

Nextcloud version (eg, 24.0.1): Nextcloud Hub 8 (29.0.6)
Talk Server version (eg, 14.0.2): 19.0.8
Custom Signaling server configured: no
Custom TURN server configured: yes
Custom STUN server configured: yes

In case the web version of Nextcloud Talk is involved:
Operating system (eg, Windows/Ubuntu/…): Ubuntu
Browser name and version (eg, Chrome v101): Version 128.0.6613.113

In case mobile Nextcloud Talk apps are involved:
Talk iOS version (eg, 14.0.2): replace me
Talk Android version (eg, 14.0.2): replace me

The issue you are facing:

  • 2 Tables are corrupted namely "oc_reactions" and "oc_tables_views". which renders Talk app broken. Could not recover and now exploring If it could be recreated using SQL ( empty table ) , chat data is not important.

Is this the first time you’ve seen this error? (Y/N): Y

These are the tables from within MariaDB:

MariaDB [nextcloud]> DESCRIBE oc_reactions;
+------------+---------------------+------+-----+---------+----------------+
| Field      | Type                | Null | Key | Default | Extra          |
+------------+---------------------+------+-----+---------+----------------+
| id         | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| parent_id  | bigint(20) unsigned | NO   | MUL | NULL    |                |
| message_id | bigint(20) unsigned | NO   |     | NULL    |                |
| actor_type | varchar(64)         | NO   |     |         |                |
| actor_id   | varchar(64)         | NO   |     |         |                |
| reaction   | varchar(32)         | NO   | MUL | NULL    |                |
+------------+---------------------+------+-----+---------+----------------+
6 rows in set (0,018 sec)

MariaDB [nextcloud]> DESCRIBE oc_tables_views;
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | int(11)      | NO   | PRI | NULL    | auto_increment |
| table_id     | int(11)      | NO   |     | NULL    |                |
| title        | varchar(200) | NO   |     | NULL    |                |
| emoji        | varchar(20)  | YES  |     | NULL    |                |
| description  | longtext     | NO   |     | NULL    |                |
| created_by   | varchar(64)  | NO   |     | NULL    |                |
| created_at   | datetime     | NO   |     | NULL    |                |
| last_edit_by | varchar(64)  | NO   |     | NULL    |                |
| last_edit_at | datetime     | NO   |     | NULL    |                |
| columns      | longtext     | YES  |     | NULL    |                |
| sort         | longtext     | YES  |     | NULL    |                |
| filter       | longtext     | YES  |     | NULL    |                |
+--------------+--------------+------+-----+---------+----------------+
12 rows in set (0,002 sec)

These are the queries to recreate them

  • oc_reactions
    • MariaDB/MySQL:
CREATE TABLE `oc_reactions` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `parent_id` bigint(20) unsigned NOT NULL,
  `message_id` bigint(20) unsigned NOT NULL,
  `actor_type` varchar(64) NOT NULL,
  `actor_id` varchar(64) NOT NULL,
  `reaction` varchar(32) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `parent_id` (`parent_id`),
  KEY `reaction` (`reaction`)
);
    • PostgreSQL:
CREATE TABLE oc_reactions (
    id SERIAL PRIMARY KEY,
    parent_id BIGINT NOT NULL,
    message_id BIGINT NOT NULL,
    actor_type VARCHAR(64) NOT NULL,
    actor_id VARCHAR(64) NOT NULL,
    reaction VARCHAR(32) NOT NULL
);
CREATE INDEX idx_parent_id ON oc_reactions(parent_id);
CREATE INDEX idx_reaction ON oc_reactions(reaction);

  • oc_tables_views:
    • MariaDB/MySQL:
CREATE TABLE `oc_tables_views` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `table_id` int(11) NOT NULL,
  `title` varchar(200) NOT NULL,
  `emoji` varchar(20) DEFAULT NULL,
  `description` longtext NOT NULL,
  `created_by` varchar(64) NOT NULL,
  `created_at` datetime NOT NULL,
  `last_edit_by` varchar(64) NOT NULL,
  `last_edit_at` datetime NOT NULL,
  `columns` longtext DEFAULT NULL,
  `sort` longtext DEFAULT NULL,
  `filter` longtext DEFAULT NULL,
  PRIMARY KEY (`id`)
);
    • PostgreSQL:
CREATE TABLE oc_tables_views (
    id SERIAL PRIMARY KEY,
    table_id INT NOT NULL,
    title VARCHAR(200) NOT NULL,
    emoji VARCHAR(20),
    description TEXT NOT NULL,
    created_by VARCHAR(64) NOT NULL,
    created_at TIMESTAMP NOT NULL,
    last_edit_by VARCHAR(64) NOT NULL,
    last_edit_at TIMESTAMP NOT NULL,
    columns TEXT,
    sort TEXT,
    filter TEXT
);

Always make backups beforehand. No guarantee!


Much and good luck,
ernolf

Thanks for your quick well explained response…

Attempted creating these tables but got “ERROR 1050 (42S01): Table ‘db.oc_reactions’ already exists” … but don’t see any files in the folder /var/lib/mysql , I had moved them out.

Anyway before I could proceed further with the troubleshooting am now getting errors for another set of tables. oc_group_folders and oc_tables_contexts_context , not sure if my env is stable now.

Sep 04 07:04:08 localhost mariadbd[46587]: 2024-09-04 7:04:08 31 [Note] InnoDB: Checksum mismatch in datafile: ./db/oc_group_folders.ibd, Space ID: 650, Flags: 21
Sep 04 07:04:08 localhost mariadbd[46587]: 2024-09-04 7:04:08 31 [ERROR] InnoDB: Could not find a valid tablespace file for db/oc_group_folders. Please refer to InnoDB Data Dictionary Troubleshooting - MariaDB Knowledge Base for how to resolve the issue.
Sep 04 07:04:10 localhost mariadbd[46587]: 2024-09-04 7:04:10 33 [Note] InnoDB: Checksum mismatch in datafile: ./db/oc_tables_contexts_context.ibd, Space ID: 534, Flags: 21
Sep 04 07:04:10 localhost mariadbd[46587]: 2024-09-04 7:04:10 33 [ERROR] InnoDB: Could not find a valid tablespace file for db/oc_tables_contexts_context. Please refer to InnoDB Data Dictionary Troubleshooting - MariaDB Knowledge Base for how to resolve the issue.

Is it a common issue in NextCloud ?

Cheers