Questions About the Raft Majority Principle

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 关于 raft 大多数原则的疑问

| username: MrSylar

When initializing a TiDB cluster, the default number of replicas is set to 3. If the number of TiKV instances is 1 during cluster initialization, the database tables will have 1 region group with 1 peer. In theory, this does not comply with the majority principle of Raft, but in practice, the cluster can still read and write. What is the principle behind this?

| username: WalterWj | Original post link

Because it is equivalent to 1 replica. Configuring 3 actually has no effect.

| username: zhanggame1 | Original post link

When initializing a TiDB cluster, you can install 1 PD, 1 TiDB, and 1 TiKV, but high availability will be lost.

| username: 路在何chu | Original post link

Then it means there is no high availability, treat it as a test environment.

| username: redgame | Original post link

My test environment is just like this.

| username: TiDBer_aaO4sU46 | Original post link

1 copy

| username: changpeng75 | Original post link

It’s equivalent to your settings overriding the default values.

| username: TIDB-Learner | Original post link

What if there are 2 TiKV instances? Has anyone tried it?

| username: zhaokede | Original post link

The number of tikv instances when initializing the cluster is 1, which means it is not highly available.

| username: Kongdom | Original post link

What I understand is that at this time it should be 1 replica.

| username: 饭光小团 | Original post link

KV instance and raft replica are two different things, right?

| username: DBAER | Original post link

Single node, even if placed on one instance, the instance failure still does not provide high availability.

| username: zhang_2023 | Original post link

Without high availability, this issue is not involved.

| username: MrSylar | Original post link

I want to see the official explanation about this mechanism. It’s quite interesting: if the number of TiKV instances is expanded at this time, the number of region peers will increase accordingly until it meets the definition of placement rules.

| username: MrSylar | Original post link

Thinking about Raft.

| username: 小于同学 | Original post link

There is no high availability.

| username: MrSylar | Original post link

Logically, I haven’t made any “active” settings. I guess the TiDB database has some “mechanism” here, but I haven’t found any content about raft mentioning this.

| username: MrSylar | Original post link

A region will have 2 peers. At this time, if one TiKV instance is forcibly down, read and write will report an error ERROR 9005 (HY000): Region is unavailable.

| username: MrSylar | Original post link

The default setting for the number of replicas is 3, and it is expected that a region includes 3 peers. When initializing, if there is only one TiKV instance, only 1 peer is actually generated, but the database is still available at this time.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.