-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.This bug affects the 8.5.x(LTS) versions.component/statisticsreport/customerCustomers have encountered this bug.Customers have encountered this bug.severity/moderatesig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
- Create the table:
use test;
CREATE TABLE `aaa` (
`id1` binary(16) AS (1),
`aaa_s1` binary(16) NOT NULL,
`aaa_m1` int NOT NULL,
`aaa_t1` enum('GOOD','BAD') COLLATE utf8mb4_general_ci NOT NULL,
`aaa_ta1` varchar(16) COLLATE utf8mb4_general_ci DEFAULT NULL,
`de1` text COLLATE utf8mb4_general_ci DEFAULT NULL,
`inat` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`upat` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY (`aaa_s1`,`aaa_m1`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
- Insert some data:
package main
import (
"database/sql"
"fmt"
"log"
"math/rand"
"sync"
"time"
_ "github.com/go-sql-driver/mysql"
)
const (
DB_URL = "root:@tcp(127.0.0.1:4000)/test"
THREAD_COUNT = 16
BATCH_SIZE = 100
RUNNING_TIME_MINUTES = 1
)
func main() {
var wg sync.WaitGroup
done := make(chan bool)
for i := 0; i < THREAD_COUNT; i++ {
wg.Add(1)
go insertTask(&wg, done, i+1)
}
go func() {
time.Sleep(RUNNING_TIME_MINUTES * time.Minute)
close(done)
}()
wg.Wait()
fmt.Println("All insert tasks completed.")
}
func insertTask(wg *sync.WaitGroup, done <-chan bool, threadID int) {
defer wg.Done()
db, err := sql.Open("mysql", DB_URL)
if err != nil {
log.Printf("Thread %d: Failed to connect to database: %v", threadID, err)
return
}
defer db.Close()
db.SetMaxOpenConns(1)
db.SetMaxIdleConns(1)
stmt, err := db.Prepare("INSERT INTO aaa (aaa_s1, aaa_m1, aaa_t1, aaa_ta1, de1) VALUES (UUID_TO_BIN(UUID()), ?, ?, ?, ?)")
if err != nil {
log.Printf("Thread %d: Failed to prepare statement: %v", threadID, err)
return
}
defer stmt.Close()
messageID := 1
for {
select {
case <-done:
fmt.Printf("Thread %d: Received stop signal\n", threadID)
return
default:
tx, err := db.Begin()
if err != nil {
log.Printf("Thread %d: Failed to begin transaction: %v", threadID, err)
continue
}
txStmt := tx.Stmt(stmt)
for i := 0; i < BATCH_SIZE; i++ {
aaaType := "BAD"
if rand.Float64() > 0.5 {
aaaType = "GOOD"
}
tag := fmt.Sprintf("TAG-%d", rand.Intn(100))
de1 := fmt.Sprintf("de for message %d", messageID)
_, err := txStmt.Exec(messageID, aaaType, tag, de1)
if err != nil {
log.Printf("Thread %d: Failed to execute insert: %v", threadID, err)
tx.Rollback()
break
}
messageID++
}
if err := tx.Commit(); err != nil {
log.Printf("Thread %d: Failed to commit transaction: %v", threadID, err)
} else {
fmt.Printf("Thread %d inserted %d records\n", threadID, BATCH_SIZE)
}
txStmt.Close()
time.Sleep(100 * time.Millisecond)
}
}
}
- Analyze the table:
analyze table aaa columns aaa_s1,aaa_m1,aaa_t1,aaa_ta1,de1,inat,upat, id1;
2. What did you expect to see? (Required)
It was successfully executed.
3. What did you see instead (Required)
test> analyze table aaa columns aaa_s1,aaa_m1,aaa_t1,aaa_ta1,de1,inat,upat, id1
[2025-06-09 15:44:32] [22001][1292] Data truncation: Incorrect datetime value: '��������H'
4. What is your TiDB version? (Required)
v8.5.1
master
Metadata
Metadata
Assignees
Labels
affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.This bug affects the 8.5.x(LTS) versions.component/statisticsreport/customerCustomers have encountered this bug.Customers have encountered this bug.severity/moderatesig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.