cockroachdb / cockroachdb/cockroach

restore: error when restoring table that uses type used by non-restored tables

Open
#98,524 1 comment 0 reactions 0 assignees View on GitHub
C-bug O-support P-3 T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

When a type is referenced by more than one table, and only one table is backed up, it cannot be restored. The error message suggests that the restored type is looking for the other tables.

**To Reproduce**

On source cluster:

```
CREATE TYPE the_type AS ENUM ('Y', 'N');

CREATE TABLE a (
id UUID PRIMARY KEY,
mytype the_type
);

CREATE TABLE b (
id UUID PRIMARY KEY,
mytype the_type
);

BACKUP TABLE a INTO 'nodelocal://1/backup';
```

On destination cluster:

```
RESTORE TABLE a FROM LATEST IN 'nodelocal://1/backup';

root@localhost:26257/defaultdb> RESTORE TABLE a FROM LATEST IN 'nodelocal://1/backup';
ERROR: type "the_type" (104): referenced descriptor ID 107: referenced descriptor not found
```

**Expected behavior**
When the backup is taken, the type should be rewritten in a way that only includes the subset of tables that are part of the backup.

**Environment:**
- CockroachDB version: All

Jira issue: CRDB-25309

Epic CRDB-61002

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.