Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
85171de
*: plumb per-column DESC flag through index metadata (phase 1 of #2519)
takaidohigasi Apr 24, 2026
e92b461
planner: honor IndexColumn.Desc when matching sort property (phase 2 …
takaidohigasi Apr 24, 2026
a23319b
codec: add EncodeKeyWithDesc/DecodeOneWithDesc primitives (phase 3a o…
takaidohigasi Apr 24, 2026
e414040
tablecodec: encode DESC index columns with complemented bytes (phase …
takaidohigasi Apr 24, 2026
686a9dc
distsql,executor,tables: wire DESC encoding through read paths (phase…
takaidohigasi Apr 24, 2026
adb81f0
codec: auto-detect DESC flag bytes in chunk Decoder (phase 3d-A of #2…
takaidohigasi Apr 24, 2026
a2407dd
planner,model: enforce IndexInfo.IsServable at plan time (#2519)
takaidohigasi Apr 25, 2026
b05e420
ddl: gate CREATE INDEX on TiKV cluster version (#2519)
takaidohigasi Apr 25, 2026
385d13f
planner: support mixed-direction composite indexes (#2519)
takaidohigasi Apr 25, 2026
82006d0
ddl: regression test for DESC on expression-index parts (#2519)
takaidohigasi Apr 25, 2026
7f506a5
ddl: lock down sysvar create-time-only semantics for DESC indexes (#2…
takaidohigasi Apr 25, 2026
be86ba2
ddl: clarify MinTiKVVersionForDescIndex is a release-coordinated TODO…
takaidohigasi Apr 25, 2026
61a14ea
ddl: reject DESC on the columns of a clustered PRIMARY KEY (#2519)
takaidohigasi Apr 25, 2026
f40e70d
executor: propagate IndexRangesToKVRangesWithDesc error in IndexMerge…
takaidohigasi Apr 25, 2026
3f246ba
planner: extend IsServable fence to LOAD DATA and IMPORT INTO (#2519)
takaidohigasi Apr 25, 2026
fcff441
ddl: bake tidb_enable_descending_index decision at SQL frontend (#2519)
takaidohigasi Apr 25, 2026
4ce9687
ddl: delay DESC preflight until after OnExistIgnore short-circuit (#2…
takaidohigasi Apr 25, 2026
3faacae
ddl: bound PD GetAllStores call with a 5s timeout (#2519)
takaidohigasi Apr 25, 2026
ffa8638
ddl: accept pre-release TiKV at the DESC index version floor (#2519)
takaidohigasi Apr 25, 2026
f89329e
planner: extend IsServable fence to writable non-public indexes (#2519)
takaidohigasi Apr 26, 2026
e9200da
ddl: clarify checkTiKVSupportsDescIndex docstring (#2519)
takaidohigasi Apr 26, 2026
49bbaca
ddl: assert idx_a presence in TestDescendingIndexSysvarIsCreateTimeOn…
takaidohigasi Apr 26, 2026
7fb5348
ddl: skip TiKV version gate for hypothetical DESC indexes (#2519)
takaidohigasi Apr 26, 2026
37f2288
planner: run IMPORT INTO servability fence on latest schema (#2519)
takaidohigasi Apr 26, 2026
8eec79a
tests: add tiup-playground e2e smoke test for descending-order indexe…
takaidohigasi Apr 26, 2026
f3d6cea
(#68096)
ChangRui-Ryan May 7, 2026
7b2b384
(#68168)
henrybw May 7, 2026
8db3298
(#68137)
qw4990 May 7, 2026
a0cdff3
(#68148)
D3Hunter May 7, 2026
b07580b
Merge remote-tracking branch 'upstream/master' into feature/desc-index
takaidohigasi May 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion br/pkg/restore/snap_client/systable_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func TestCheckPrivilegeTableRowsCollateCompatibility(t *testing.T) {
//
// The above variables are in the file br/pkg/restore/systable_restore.go
func TestMonitorTheSystemTableIncremental(t *testing.T) {
require.Equal(t, int64(258), session.CurrentBootstrapVersion)
require.Equal(t, int64(259), session.CurrentBootstrapVersion)
}

func TestIsStatsTemporaryTable(t *testing.T) {
Expand Down
36 changes: 31 additions & 5 deletions cmd/tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"strconv"
"strings"
"sync/atomic"
"syscall"
"time"

"github.com/grafana/pyroscope-go"
Expand Down Expand Up @@ -145,6 +146,12 @@ const (
nmMaxIdleSeconds = "max-idle-seconds"
)

const (
exitCodeOK = 0
exitCodeErr = 1
exitCodeInt = 128 + int(syscall.SIGINT)
)

var (
version *bool
configPath *string
Expand Down Expand Up @@ -403,31 +410,50 @@ func main() {
}

exited := make(chan struct{})
signal.SetupSignalHandler(func() {
exitCode := exitCodeOK
signal.SetupSignalHandler(func(sig os.Signal) {
svr.Close()
resourcemanager.InstanceResourceManager.Stop()
cleanup(svr, storage, dom)
cpuprofile.StopCPUProfiler()
executor.Stop()
exitCode = exitCodeForSignal(sig)
close(exited)
})
topsql.SetupTopProfiling(keyspace.GetKeyspaceNameBytesBySettings(), svr, dom)
terror.MustNil(svr.Run(dom))
<-exited
syncLog()
if err := syncLog(); err != nil {
// Log sync failure means shutdown did not finish cleanly, so keep
// reporting it as a generic non-zero exit instead of a successful exit.
exitCode = exitCodeErr
}
if exitCode != exitCodeOK {
os.Exit(exitCode)
}
}

func syncLog() {
func exitCodeForSignal(sig os.Signal) int {
// Standby force shutdown uses SIGINT. Return 128+SIGINT so deployment scripts
// can identify this force-shutdown path.
if sig == syscall.SIGINT {
return exitCodeInt
}
return exitCodeOK
}

func syncLog() error {
if err := log.Sync(); err != nil {
// Don't complain about /dev/stdout as Fsync will return EINVAL.
if pathErr, ok := err.(*fs.PathError); ok {
if pathErr.Path == "/dev/stdout" {
os.Exit(0)
return nil
}
}
fmt.Fprintln(os.Stderr, "sync log err:", err)
os.Exit(1)
return err
}
return nil
}

func checkTempStorageQuota() error {
Expand Down
21 changes: 21 additions & 0 deletions cmd/tidb-server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main

import (
"os"
"syscall"
"testing"

"github.com/pingcap/tidb/pkg/config"
Expand Down Expand Up @@ -51,6 +52,26 @@ func TestRunMain(t *testing.T) {
}
}

func TestExitCodeForSignal(t *testing.T) {
tests := []struct {
name string
sig os.Signal
want int
}{
{name: "SIGINT", sig: syscall.SIGINT, want: exitCodeInt},
{name: "SIGTERM", sig: syscall.SIGTERM, want: exitCodeOK},
{name: "SIGHUP", sig: syscall.SIGHUP, want: exitCodeOK},
{name: "SIGQUIT", sig: syscall.SIGQUIT, want: exitCodeOK},
{name: "nil", sig: nil, want: exitCodeOK},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.want, exitCodeForSignal(tt.sig))
})
}
}

func TestSetGlobalVars(t *testing.T) {
defer view.Stop()
require.Equal(t, "tikv,tiflash,tidb", variable.GetSysVar(vardef.TiDBIsolationReadEngines).Value)
Expand Down
4 changes: 2 additions & 2 deletions lightning/tests/lightning_write_timeout/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ for i in {1..200000}; do
done
set -x

export GO_FAILPOINTS="github.com/pingcap/tidb/pkg/lightning/backend/local/shortWaitNTimeout=100*return(1)"
export GO_FAILPOINTS="github.com/pingcap/tidb/pkg/lightning/backend/local/shortWaitNTimeout=5*return(1000)"

run_lightning --backend local -d "$TEST_DIR/data" --config "$CUR/config.toml"
check_lightning_log_contains 'Experiencing a wait timeout while writing to tikv'
check_lightning_log_contains 'experiencing a wait timeout while writing to TiKV'
20 changes: 20 additions & 0 deletions pkg/ddl/create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,14 @@ func BuildSessionTemporaryTableInfo(ctx *metabuild.Context, store kv.Storage, is

// BuildTableInfoWithStmt builds model.TableInfo from a SQL statement without validity check
func BuildTableInfoWithStmt(ctx *metabuild.Context, s *ast.CreateTableStmt, dbCharset, dbCollate string, placementPolicyRef *model.PolicyRefInfo) (*model.TableInfo, error) {
// Apply tidb_enable_descending_index gate up front, before any constraint
// processing. See ApplyDescGateToIndexParts for the rationale: baking the
// decision in at submission time prevents a `SET GLOBAL` between statement
// submission and DDL owner replay from silently flipping the persisted
// schema.
for _, c := range s.Constraints {
ApplyDescGateToIndexParts(c.Keys)
}
colDefs := s.Cols
tableCharset, tableCollate, err := GetCharsetAndCollateInTableOption(0, s.Options, ctx.GetDefaultCollationForUTF8MB4())
if err != nil {
Expand Down Expand Up @@ -1337,6 +1345,18 @@ func BuildTableInfo(
isSingleIntPK := isSingleIntPKFromTableInfo(constr, tbInfo)

if ShouldBuildClusteredIndex(ctx.GetClusteredIndexDefMode(), constr.Option, isSingleIntPK) {
// Reject DESC on the columns of a clustered PRIMARY KEY.
// For PKIsHandle (single-int PK) the column becomes the
// row's int handle directly and BuildIndexInfo is never
// invoked, so this guard catches that case. For
// IsCommonHandle the same check fires again inside
// BuildIndexInfo for defence-in-depth. See pingcap/tidb#2519.
for _, key := range constr.Keys {
if key.Desc {
return nil, errors.Errorf(
"DESC is not supported on the columns of a clustered PRIMARY KEY; either drop the DESC keyword or declare the primary key as NONCLUSTERED")
}
}
if isSingleIntPK {
tbInfo.PKIsHandle = true
} else {
Expand Down
Loading
Loading