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

infoschema: fix information schema data race #7318

Merged
merged 3 commits into from
Aug 8, 2018

Conversation

alivxxx
Copy link
Contributor

@alivxxx alivxxx commented Aug 8, 2018

What have you changed? (mandatory)

When applying the changes to DBInfo, we should not directly modify it, because it may be referenced by others.

What is the type of the changes? (mandatory)

  • Bug fix (non-breaking change which fixes an issue)

How has this PR been tested? (mandatory)

Tested in #7305

Does this PR affect documentation (docs/docs-cn) update? (mandatory)

No.

Does this PR affect tidb-ansible update? (mandatory)

No.

Does this PR need to be added to the release notes? (mandatory)

No.

Refer to a related PR or issue link (optional)

Benchmark result if necessary (optional)

Add a few positive/negative examples (optional)

PTAL @coocood @zimulala

@alivxxx alivxxx added the type/bugfix This PR fixes a bug. label Aug 8, 2018
Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@winoros winoros added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 8, 2018
Copy link
Contributor

@tiancaiamao tiancaiamao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -187,31 +189,31 @@ func (b *Builder) applyCreateTable(m *meta.Meta, roDBInfo *model.DBInfo, tableID

newTbl, ok := b.is.TableByID(tableID)
if ok {
roDBInfo.Tables = append(roDBInfo.Tables, newTbl.Meta())
dbInfo.Tables = append(dbInfo.Tables, newTbl.Meta())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, here is the race?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here may have the race.

} else {
roDBInfo.Tables = append(roDBInfo.Tables[:i], roDBInfo.Tables[i+1:]...)
dbInfo.Tables = append(dbInfo.Tables[:i], dbInfo.Tables[i+1:]...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or here?
In the PR description, you'd better post the data race log, so it's easier for us to understand where is the cause of the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually happens here in the log, but I browse the file and find more places that may have the race.

@tiancaiamao tiancaiamao added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 8, 2018
tiancaiamao
tiancaiamao previously approved these changes Aug 8, 2018
@tiancaiamao
Copy link
Contributor

/run-all-tests

@alivxxx
Copy link
Contributor Author

alivxxx commented Aug 8, 2018

/run-unit-test

@alivxxx
Copy link
Contributor Author

alivxxx commented Aug 8, 2018

/run-all-tests

@alivxxx alivxxx merged commit cd45803 into pingcap:master Aug 8, 2018
@alivxxx alivxxx deleted the infoschema branch August 8, 2018 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants