Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 创建索引卡死
[Test Environment for TiDB] Testing
[TiDB Version] 7.1.0
[Reproduction Path] Creating an index
[Encountered Problem: Phenomenon and Impact]
index
CREATE UNIQUE INDEX uni_xx_xx ON xx.xx (tx_id, sequence);
Stuck
Log:
[ddl_worker.go:980] [“[ddl] run DDL job”] [worker=“worker 7, tp add index”] [job=“ID:152, Type:add index, State:running, SchemaState:none, SchemaID:146, TableID:150, RowCount:0, ArgLen:0, start time: 2023-07-25 09:17:03.05 +0000 UTC, Err:[ddl:-1]cannot get disk capacity at /tmp/tidb/tmp_ddl-4000: no such file or directory, ErrCount:510, SnapshotVersion:0, UniqueWarnings:0”]
Was it upgraded from a lower version? Try manually creating the /tmp/tidb/tmp_ddl-4000 directory and granting the necessary permissions before trying again.
I’ve seen this issue several times. Manually create the /tmp/tidb/tmp_ddl-4000 directory.
Every few days, someone asks about this. If the error directory doesn’t exist, create it manually. If it does exist, give it 777 permissions.
What is the root cause? How can it be avoided?
Self Q&A: This bug has been fixed.
For the reason, please refer to
pingcap:master
← tangenta:add-index-tempdir-auto
opened 01:50AM - 19 Jul 23 UTC
<!--
Thank you for contributing to TiDB!
PR Title Format:
1. pkg [, pkg2,… pkg3]: what's changed
2. *: what's changed
-->
### What problem does this PR solve?
<!--
Please create an issue first to describe the problem.
There MUST be one line starting with "Issue Number: " and
linking the relevant issues via the "close" or "ref".
For more info, check https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/contribute-code.html#referring-to-an-issue.
-->
Issue Number: close #45456
Problem Summary:
#43210 added the `PrecheckUsage()` function which depends on the existence of temp dir. However, the automatically creation of temp dir happens after `PrecheckUsage()`. It cause the unexpected behavior.
### What is changed and how it works?
Create temp dir automatically for adding index.
### Check List
Tests
- [ ] Unit test
- [ ] Integration test
- [x] Manual test (add detailed scripts or steps below)
Terminal 1:
```
mysql> alter table t1 add index idx(k);
Query OK, 0 rows affected (2.59 sec)
```
Terminal 2:
```
➜ tidb ls
import-4000
➜ tidb ls
import-4000 tmp_ddl-4000
```
- [ ] No code
Side effects
- [ ] Performance regression: Consumes more CPU
- [ ] Performance regression: Consumes more Memory
- [ ] Breaking backward compatibility
Documentation
- [ ] Affects user behaviors
- [ ] Contains syntax changes
- [ ] Contains variable changes
- [ ] Contains experimental features
- [ ] Changes MySQL compatibility
### Release note
Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.
```release-note
None
```
Configure temp-dir to an available path, or manually create the default path for temp-dir at /tmp/tidb
I encountered this problem today as well. I upgraded from version 7.0.0, but I don’t know why this directory wasn’t created automatically.
This is a bug, waiting for a fix.
The fix is already included in v7.1.1.
Check the permissions of the /tmp/tidb/tmp_ddl-4000 directory.
The version I am using is 7.1.1, but this version was upgraded from version 7.1.0, and there is no such directory.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.