Skip to content

Commit d9f9374

Browse files
yikekelilin90
authored andcommitted
sql: update the step of the "Auto Increment ID" (#577)
Via: pingcap/docs-cn#842
1 parent c7df2e0 commit d9f9374

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sql/mysql-compatibility.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ The auto-increment ID feature in TiDB is only guaranteed to be automatically inc
4141
> create table t(id int unique key auto_increment, c int);
4242
> ```
4343
>
44-
> The principle of the auto-increment ID in TiDB is that each tidb-server instance caches a section of ID values for allocation and fetches the next section after this section is used up.
44+
> The principle of the auto-increment ID in TiDB is that each tidb-server instance caches a section of ID values (currently 30000 IDs are cached) for allocation and fetches the next section after this section is used up.
4545
>
46-
> Assume that the cluster contains two tidb-server instances, namely Instance A and Instance B. Instance A caches the auto-increment ID of [1, 5000], while Instance B caches the auto-increment ID of [5001, 10000].
46+
> Assume that the cluster contains two tidb-server instances, namely Instance A and Instance B. Instance A caches the auto-increment ID of [1, 30000], while Instance B caches the auto-increment ID of [30001, 60000].
4747
>
4848
> The operations are executed as follows:
4949
>
5050
> 1. The client issues the `insert into t values (1, 1)` statement to Instance B which sets the `id` to 1 and the statement is executed successfully.
51-
> 2. The client issues the `insert into t (c) (1)` statement to Instance A. This statement does not specify the value of `id`, so Instance A allocates the value. Currently, Instances A caches the auto-increment ID of [1, 5000], so it allocates the `id` value to 1 and adds 1 to the local counter. However, at this time the data with the `id` of 1 already exists in the cluster, therefore it reports `Duplicated Error`.
51+
> 2. The client issues the `insert into t (c) (1)` statement to Instance A. This statement does not specify the value of `id`, so Instance A allocates the value. Currently, Instances A caches the auto-increment ID of [1, 30000], so it allocates the `id` value to 1 and adds 1 to the local counter. However, at this time the data with the `id` of 1 already exists in the cluster, therefore it reports `Duplicated Error`.
5252
5353
### Built-in functions
5454

0 commit comments

Comments
 (0)