[
https://issues.apache.org/jira/browse/CASSANDRA-21622?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Michael Semb Wever updated CASSANDRA-21622:
-------------------------------------------
Description:
{{TruncateStatement.validate}} calls {{Schema.instance.validateTable}}, so an
unknown table is rejected before execution. A {{DROP TABLE}} that commits
between {{validate}} and {{execute}} leaves no metadata, and both execution
paths read {{isView()}} on the result of {{Schema.instance.getTableMetadata}}
with no null test:
{code:java}
TableMetadata metaData = Schema.instance.getTableMetadata(keyspace(), name());
if (metaData.isView())
throw new InvalidRequestException("Cannot TRUNCATE materialized view
directly; ...");
{code}
{{execute}} then answers a {{NullPointerException}} to the client, and
{{executeLocally}} wraps one in a {{TruncateException}}, which reads as a
truncation failure rather than as a table that is gone. The severity is Low
because the window is the schema propagation of a concurrent drop.
The patch tests the metadata for null and reports the unknown keyspace and
table, which is the message the same race already produces for other statements.
Patch:
[mck/CASSANDRA-21622/5.0|https://github.com/thelastpickle/cassandra/tree/mck/CASSANDRA-21622/5.0]
Provenance:
[5f1d03c5ed|https://github.com/datastax/cassandra/commit/5f1d03c5edf26af6078ce70de456fadc87d46fa5]
by [~djatnieks]. That commit adds the same two null tests; the rest of it
moves {{doTruncateBlocking}} so a fork implementation can override the call,
which upstream has no need of, so this patch takes the null tests alone and
adds the regression test the commit lacks.
was:
{{TruncateStatement.validate}} calls {{Schema.instance.validateTable}}, so an
unknown table is rejected before execution. A {{DROP TABLE}} that commits
between {{validate}} and {{execute}} leaves no metadata, and both execution
paths read {{isView()}} on the result of {{Schema.instance.getTableMetadata}}
with no null test:
{code:java}
TableMetadata metaData = Schema.instance.getTableMetadata(keyspace(), name());
if (metaData.isView())
throw new InvalidRequestException("Cannot TRUNCATE materialized view
directly; ...");
{code}
{{execute}} then answers a {{NullPointerException}} to the client, and
{{executeLocally}} wraps one in a {{TruncateException}}, which reads as a
truncation failure rather than as a table that is gone. The severity is Low
because the window is the schema propagation of a concurrent drop.
The patch tests the metadata for null and reports the unknown keyspace and
table, which is the message the same race already produces for other statements.
Patch:
[mck/upstream/truncate-unknown-table/5.0|https://github.com/thelastpickle/cassandra/tree/mck/upstream/truncate-unknown-table/5.0]
Provenance:
[5f1d03c5ed|https://github.com/datastax/cassandra/commit/5f1d03c5edf26af6078ce70de456fadc87d46fa5]
by dan jatnieks. That commit adds the same two null tests; the rest of it
moves {{doTruncateBlocking}} so a fork implementation can override the call,
which upstream has no need of, so this patch takes the null tests alone and
adds the regression test the commit lacks.
> TRUNCATE answers a NullPointerException when the table is dropped during
> execution
> ----------------------------------------------------------------------------------
>
> Key: CASSANDRA-21622
> URL: https://issues.apache.org/jira/browse/CASSANDRA-21622
> Project: Apache Cassandra
> Issue Type: Bug
> Components: CQL/Semantics
> Reporter: Michael Semb Wever
> Priority: Normal
> Fix For: 5.0.x, 6.0.x, 7.x
>
>
> {{TruncateStatement.validate}} calls {{Schema.instance.validateTable}}, so an
> unknown table is rejected before execution. A {{DROP TABLE}} that commits
> between {{validate}} and {{execute}} leaves no metadata, and both execution
> paths read {{isView()}} on the result of {{Schema.instance.getTableMetadata}}
> with no null test:
> {code:java}
> TableMetadata metaData = Schema.instance.getTableMetadata(keyspace(), name());
> if (metaData.isView())
> throw new InvalidRequestException("Cannot TRUNCATE materialized view
> directly; ...");
> {code}
> {{execute}} then answers a {{NullPointerException}} to the client, and
> {{executeLocally}} wraps one in a {{TruncateException}}, which reads as a
> truncation failure rather than as a table that is gone. The severity is Low
> because the window is the schema propagation of a concurrent drop.
> The patch tests the metadata for null and reports the unknown keyspace and
> table, which is the message the same race already produces for other
> statements.
> Patch:
> [mck/CASSANDRA-21622/5.0|https://github.com/thelastpickle/cassandra/tree/mck/CASSANDRA-21622/5.0]
> Provenance:
> [5f1d03c5ed|https://github.com/datastax/cassandra/commit/5f1d03c5edf26af6078ce70de456fadc87d46fa5]
> by [~djatnieks]. That commit adds the same two null tests; the rest of it
> moves {{doTruncateBlocking}} so a fork implementation can override the call,
> which upstream has no need of, so this patch takes the null tests alone and
> adds the regression test the commit lacks.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]