Update table binlog config disable failure when db binlog is enable && (#22253)

modify table binlog more than one property

Signed-off-by: Jack Drogon <jack.xsuperman@gmail.com>
This commit is contained in:
Jack Drogon
2023-07-27 09:54:24 +08:00
committed by GitHub
parent 8fb28ecc9e
commit 82fe78ce84
2 changed files with 19 additions and 4 deletions

View File

@ -2804,7 +2804,7 @@ public class SchemaChangeHandler extends AlterHandler {
BinlogConfig oldBinlogConfig;
BinlogConfig newBinlogConfig;
db.readLock();
olapTable.readLock();
try {
oldBinlogConfig = new BinlogConfig(olapTable.getBinlogConfig());
newBinlogConfig = new BinlogConfig(oldBinlogConfig);
@ -2812,7 +2812,7 @@ public class SchemaChangeHandler extends AlterHandler {
} catch (Exception e) {
throw new DdlException(e.getMessage());
} finally {
db.readUnlock();
olapTable.readUnlock();
}
for (AlterClause alterClause : alterClauses) {
@ -2858,6 +2858,19 @@ public class SchemaChangeHandler extends AlterHandler {
return true;
}
// check db binlog config, if db binlog config is not same as table binlog config, throw exception
BinlogConfig dbBinlogConfig;
db.readLock();
try {
dbBinlogConfig = new BinlogConfig(db.getBinlogConfig());
} finally {
db.readUnlock();
}
boolean dbBinlogEnable = (dbBinlogConfig != null && dbBinlogConfig.isEnable());
if (dbBinlogEnable && !newBinlogConfig.isEnable()) {
throw new DdlException("db binlog is enable, but table binlog is disable");
}
LOG.info("begin to update table's binlog config. table: {}, old binlog: {}, new binlog: {}",
olapTable.getName(), oldBinlogConfig, newBinlogConfig);

View File

@ -66,8 +66,10 @@ public class ModifyTablePropertiesClause extends AlterTableClause {
}
if (properties.size() != 1
&& !TableProperty.isSamePrefixProperties(properties, TableProperty.DYNAMIC_PARTITION_PROPERTY_PREFIX)) {
throw new AnalysisException("Can only set one table property at a time");
&& !TableProperty.isSamePrefixProperties(properties, TableProperty.DYNAMIC_PARTITION_PROPERTY_PREFIX)
&& !TableProperty.isSamePrefixProperties(properties, PropertyAnalyzer.PROPERTIES_BINLOG_PREFIX)) {
throw new AnalysisException(
"Can only set one table property(without dynamic partition && binlog) at a time");
}
if (properties.containsKey(PropertyAnalyzer.PROPERTIES_COLOCATE_WITH)) {