Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test TestExchangePartitionWithPlacement fails after injecting full reload #54796

Closed
wjhuang2016 opened this issue Jul 22, 2024 · 1 comment · Fixed by #54831
Closed

Test TestExchangePartitionWithPlacement fails after injecting full reload #54796

wjhuang2016 opened this issue Jul 22, 2024 · 1 comment · Fixed by #54831
Assignees
Labels
component/test feature/developing the related feature is in development severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@wjhuang2016
Copy link
Member

wjhuang2016 commented Jul 22, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Enable info schema cache V2.

Modify codes

func (do *Domain) tryLoadSchemaDiffs(m *meta.Meta, usedVersion, newVersion int64, startTS uint64) (infoschema.InfoSchema, *transaction.RelatedSchemaChange, []string, error) {
	var diffs []*model.SchemaDiff
	for usedVersion < newVersion {
		usedVersion++
		diff, err := m.GetSchemaDiff(usedVersion)
		if err != nil {
			return nil, nil, nil, err
		}
		if diff == nil {
			// Empty diff means the txn of generating schema version is committed, but the txn of `runDDLJob` is not or fail.
			// It is safe to skip the empty diff because the infoschema is new enough and consistent.
			logutil.BgLogger().Info("diff load InfoSchema get empty schema diff", zap.Int64("version", usedVersion))
			do.infoCache.InsertEmptySchemaVersion(usedVersion)
			continue
		}
		diffs = append(diffs, diff)
	}
	if diffs[0].Type == model.ActionExchangeTablePartition {
		return nil, nil, nil, errors.New("mock error")
	}
	builder, err := infoschema.NewBuilderV3(do, do.sysFacHack, do.infoCache.Data).InitWithOldInfoSchema(do.infoCache.GetLatest())
	if err != nil {
		return nil, nil, nil, errors.Trace(err)
	}

Inject mock error if DDL type is ActionExchangeTablePartition.

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

Test TestExchangePartitionWithPlacement passes.

3. What did you see instead (Required)

Test TestExchangePartitionWithPlacement fails.

4. What is your TiDB version? (Required)

master

@wjhuang2016 wjhuang2016 added the type/bug The issue is confirmed as a bug. label Jul 22, 2024
@wjhuang2016
Copy link
Member Author

Root cause analysis:
image

infoData calls remove() only in applyDropTableV2.
If the schema is fully reloaded instead of partially reloaded, the table that should be removed from the B-tree cache is still there. Then the later used would be incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/test feature/developing the related feature is in development severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants