Skip to content

workload/schemachange: ensure unique column numbers upon table creation#58038

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
jayshrivastava:fix-segfault-schemachange-workload
Dec 17, 2020
Merged

workload/schemachange: ensure unique column numbers upon table creation#58038
craig[bot] merged 1 commit intocockroachdb:masterfrom
jayshrivastava:fix-segfault-schemachange-workload

Conversation

@jayshrivastava
Copy link
Copy Markdown
Contributor

@jayshrivastava jayshrivastava commented Dec 17, 2020

workload/schemachange: ensure unique column numbers upon table creation

Previously, the following behaviour would result in a seg fault:
First a table (eg. table1) gets created with col1_0, col1_1, col1_2
where thec column numbers (0,1,2) refer to their index in the table.
After table creation, the workload tries to intentionally cause an
error by altering the type of a column that does not exist. From the
perspective of the workload, the sequence numbers (0,1,2) have not
been used, so it may use one of the column names above (eg. col1_0)
while assuming the column name is unique compared to any column names
in the db. This assumption leads to a seg fault because it is not
correct. Specifically, a column variable representing a column that
does not exist will have a nil type. If the workload checks the database
for this column, sees that it exists, then tries to dereference the type,
a seg fault will occur.

This change ensures that table creation uses the workload's atomically
increasing global sequence number while naming columns. This ensures
that the assumption above holds true and prevents the seg fault from
occurring.

Closes: #58017

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Previously, the following behaviour would result in a seg fault:
First a table (eg. table1) gets created with col1_0, col1_1, col1_2
where thec column numbers (0,1,2) refer to their index in the table.
After table creation, the workload tries to intentionally cause an
error by altering the type of a column that does not exist. From the
perspective of the workload, the sequence numbers (0,1,2) have not
been used, so it may use one of the column names above (eg. col1_0)
while assuming the column name is unique compared to any column names
in the db. This assumption leads to a seg fault because it is not
correct. Specifically, a column variable representing a column that
does not exist will have a nil type. If the workload checks the database
for this column, sees that it exists, then tries to dereference the type,
a seg fault will occur.

This change ensures that table creation uses the workload's atomically
increasing global sequence number while naming columns. This ensures
that the assumption above holds true and prevents the seg fault from
occurring.

Closes: cockroachdb#58017

Release note: None
@jayshrivastava jayshrivastava force-pushed the fix-segfault-schemachange-workload branch from cbcaa88 to a122abf Compare December 17, 2020 19:04
Copy link
Copy Markdown
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

@jayshrivastava
Copy link
Copy Markdown
Contributor Author

bors r=ajwerner

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Dec 17, 2020

Build succeeded:

@craig craig bot merged commit 3623b73 into cockroachdb:master Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

roachtest: acceptance/version-upgrade failure

3 participants