Skip to content

DB Crashes on startup if accord tables exist but accord is disabled #4197

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ public Keyspaces apply(ClusterMetadata metadata)
if (table.params.transactionalMode.accordIsEnabled && SchemaConstants.isSystemKeyspace(keyspaceName))
throw ire("Cannot enable accord on system tables (%s.%s)", keyspaceName, tableName);

if (table.params.transactionalMode.accordIsEnabled && !DatabaseDescriptor.getAccordTransactionsEnabled())
throw ire(format("Cannot create table %s.%s with transactional mode %s with accord.enabled set to false",
keyspaceName, tableName, table.params.transactionalMode));

if (table.params.transactionalMigrationFrom.isMigrating())
throw ire("Cannot set transactional migration on new tables (%s.%s), %s", keyspaceName, tableName, table.params.transactionalMigrationFrom);

Expand All @@ -193,7 +189,6 @@ public Keyspaces apply(ClusterMetadata metadata)
public void validate(ClientState state)
{
super.validate(state);

// If a memtable configuration is specified, validate it against config
if (attrs.hasOption(TableParams.Option.MEMTABLE))
MemtableParams.get(attrs.getString(TableParams.Option.MEMTABLE.toString()));
Expand All @@ -203,7 +198,14 @@ public void validate(ClientState state)

// Guardrail on columns per table
Guardrails.columnsPerTable.guard(rawColumns.size(), tableName, false, state);
TableParams params = attrs.asNewTableParams(keyspaceName);

// Guardrail on Accord
if (params.transactionalMode.accordIsEnabled && !DatabaseDescriptor.getAccordTransactionsEnabled())
{
throw ire(format("Cannot create table %s with transactional mode set to full and accord disabled. Enable Accord in cassandra.yaml",
tableName));
}
// Guardrail on number of tables
if (Guardrails.tables.enabled(state))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.cassandra.exceptions.InvalidRequestException;
import org.apache.cassandra.exceptions.RequestValidationException;
import org.apache.cassandra.utils.BloomCalculations;
import org.apache.cassandra.config.DatabaseDescriptor;

import org.junit.Test;

Expand Down Expand Up @@ -91,6 +92,14 @@ public void testCreateTableWithMissingClusteringColumn()
"Missing CLUSTERING ORDER for column ck1");
}

@Test
public void testCreateAccordTableWithAccordDisabled()
{
DatabaseDescriptor.setAccordTransactionsEnabled(false);
expectedFailure(InvalidRequestException.class, "CREATE TABLE test_accord_disabled (a int PRIMARY KEY, b int) WITH transactional_mode = full",
"Cannot create table test_accord_disabled with transactional mode set to full and accord disabled. Enable Accord in cassandra.yaml");
}

private void expectedFailure(final Class<? extends RequestValidationException> exceptionType, String statement, String errorMsg)
{

Expand Down