Skip to content

Commit 0121e99

Browse files
authored
Merge pull request pingcap#3 from iosmanthus/iosmanthus/keyspace_rfc
rfc: add TiFlash keyspace sections
2 parents 7b29bba + 3b339d6 commit 0121e99

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/design/2022-12-06-Keyspace.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,39 @@ So the [`RangeScanner`](https://github.com/iosmanthus/tikv/components/tidb_query
148148

149149
### TiFlash
150150

151+
TiFlash is a columnar storage engine that serves as a coprocessor for TiKV. By accelerating TiDB queries, TiFlash improves performance. When TiDB is enabled with a keyspace, TiFlash requests also carry the keyspace prefix. TiFlash's data structures and storage paths are segregated by keyspace ID.
152+
153+
#### Storage
154+
155+
Without keyspace, TiFlash stores each table's columnar/schema data in a separate directory identified by the table ID. However, in a keyspace scenario, multiple keyspaces may share the same table ID, so the table ID alone cannot uniquely identify a table.
156+
157+
TiFlash's storage path structure will be as follows:
158+
```
159+
.
160+
├── data
161+
│ ├── ks_1_t_92
162+
│ │ ├── data
163+
├── metadata
164+
│ ├── ks_1_db_1
165+
│ │ └── ks_1_t_92.sql
166+
│ ├── ks_1_db_2
167+
│ └── system
168+
```
169+
170+
Each table directory will be identified by both the keyspace ID and table ID.
171+
172+
#### Cache
173+
174+
When decoding row data into columnar format, TiFlash ignores the keyspace prefix. Table-related cache structures will be refactored into a map of `<KeyspaceID, TableID> -> <ValueType>` instead of `<TableID> -> <ValueType>`.
175+
176+
#### Schema sync
177+
178+
When syncing schema from TiDB to TiFlash, TiFlash adds the keyspace prefix to requests to TiKV for specific table schemas.
179+
180+
#### Request handling
181+
182+
TiFlash requests carry the keyspace prefix. TiFlash parses `<KeyspaceID, TableID>` from the encoded key range and uses it to route requests to the relevant table storage.
183+
184+
### Placement Rules
185+
186+
Placement rules are isolated by keyspace. TiDB must name placement rules with the keyspace prefix, such as `keyspace-<keyspace_id>-xxxx`. Additionally, the key range of some rules must be encoded.

0 commit comments

Comments
 (0)