Skip to content

TSO retrieval failure during read TS validation caused by residual txn-scope code #59402

@ekexium

Description

@ekexium

Bug Report

Please answer these questions before submitting your issue. Thanks!

Related to #58838

1. Minimal reproduce step (Required)

It can be triggered by either stale read or tidb_replica_read=closest-replicas, but not for closest-adaptive.

func TestTxnScopeAndValidateReadTs(t *testing.T) {
	defer config.RestoreFunc()()
	config.UpdateGlobal(func(conf *config.Config) {
		conf.Labels = map[string]string{
			"zone": "bj",
		}
	})

	store := realtikvtest.CreateMockStoreAndSetup(t)
	tk := testkit.NewTestKit(t, store)
	tk.MustExec("use test")
	tk.MustExec("create table t1 (id int primary key);")
	time.Sleep(time.Second)

	// stale read will fail
	//tk.MustQuery("select * from t1 AS OF TIMESTAMP NOW() where id = 1;").Check(testkit.Rows())

	// replica read
	// fail
	//tk.MustExec("set @@tidb_replica_read = 'closest-replicas';")

	// succeed
	//tk.MustExec("set @@tidb_replica_read = 'follower';")

	// succeed, because of https://github.com/pingcap/tidb/blob/f684d41f3e9e17777f6e19e2f9852457eed00ca6/pkg/sessiontxn/isolation/base.go#L178
	//tk.MustExec("set @@tidb_replica_read = 'closest-adaptive';")
	
	tk.MustExec("begin")
	tk.MustQuery("select * from t1 where id = 1;").Check(testkit.Rows())
}

2. What did you expect to see? (Required)

Test passes.

3. What did you see instead (Required)

error:

fail to validate read timestamp: [PD:client:ErrClientGetTSO]get TSO failed, unknown dc-location bj to the client

4. What is your TiDB version? (Required)

LTS versions in [v6.5, v8.5] which has picked tikv/client-go#1513, for example v8.5.1

Sub-issues

Metadata

Metadata

Assignees

Labels

affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.affects-9.0This bug affects the 9.0.x versions.report/customerCustomers have encountered this bug.severity/criticalsig/transactionSIG:Transactiontype/bugThe issue is confirmed as a bug.type/regression

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions