Skip to content

Commit 61e405b

Browse files
authored
Revert "Show pre-deleted table schemas and improve write errors (#18626)" (#18762)
This reverts commit 3b47945.
1 parent 4092a78 commit 61e405b

27 files changed

Lines changed: 49 additions & 1819 deletions

File tree

‎iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlan.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
import org.apache.iotdb.confignode.consensus.request.write.table.RenameTableColumnPlan;
117117
import org.apache.iotdb.confignode.consensus.request.write.table.RenameTablePlan;
118118
import org.apache.iotdb.confignode.consensus.request.write.table.RollbackCreateTablePlan;
119-
import org.apache.iotdb.confignode.consensus.request.write.table.RollbackPreAlterColumnDataTypePlan;
120119
import org.apache.iotdb.confignode.consensus.request.write.table.RollbackPreDeleteTablePlan;
121120
import org.apache.iotdb.confignode.consensus.request.write.table.SetTableColumnCommentPlan;
122121
import org.apache.iotdb.confignode.consensus.request.write.table.SetTableCommentPlan;
@@ -464,9 +463,6 @@ public static ConfigPhysicalPlan create(final ByteBuffer buffer) throws IOExcept
464463
case PreAlterColumnDataType:
465464
plan = new PreAlterColumnDataTypePlan();
466465
break;
467-
case RollbackPreAlterColumnDataType:
468-
plan = new RollbackPreAlterColumnDataTypePlan();
469-
break;
470466
case AlterColumnDataType:
471467
plan = new AlterColumnDataTypePlan();
472468
break;

‎iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/ConfigPhysicalPlanType.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ public enum ConfigPhysicalPlanType {
233233
AlterColumnDataType((short) 878),
234234
PreAlterColumnDataType((short) 879),
235235
RollbackPreDeleteTable((short) 880),
236-
RollbackPreAlterColumnDataType((short) 881),
237236

238237
/** Deprecated types for sync, restored them for upgrade. */
239238
@Deprecated

‎iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/table/RollbackPreAlterColumnDataTypePlan.java‎

Lines changed: 0 additions & 61 deletions
This file was deleted.

‎iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java‎

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.apache.iotdb.common.rpc.thrift.TSStatus;
2525
import org.apache.iotdb.commons.conf.CommonDescriptor;
2626
import org.apache.iotdb.commons.exception.MetadataException;
27-
import org.apache.iotdb.commons.exception.table.TableInDeletionException;
2827
import org.apache.iotdb.commons.path.PartialPath;
2928
import org.apache.iotdb.commons.path.PathPatternTree;
3029
import org.apache.iotdb.commons.schema.SchemaConstant;
@@ -1541,34 +1540,13 @@ public Optional<Pair<TsTable, TableNodeStatus>> getTableAndStatusIfExists(
15411540
return clusterSchemaInfo.getTsTableIfExists(database, tableName);
15421541
}
15431542

1544-
public boolean isColumnAlterCommitted(
1545-
final String database,
1546-
final String tableName,
1547-
final String columnName,
1548-
final TSDataType dataType)
1549-
throws MetadataException {
1550-
return clusterSchemaInfo.isColumnAlterCommitted(database, tableName, columnName, dataType);
1551-
}
1552-
1553-
public Optional<TSDataType> getPreAlteredColumnType(
1554-
final String database, final String tableName, final String columnName)
1555-
throws MetadataException {
1556-
return clusterSchemaInfo.getPreAlteredColumnType(database, tableName, columnName);
1557-
}
1558-
15591543
public synchronized Pair<TSStatus, TsTable> tableColumnCheckForColumnExtension(
15601544
final String database,
15611545
final String tableName,
15621546
final List<TsTableColumnSchema> columnSchemaList,
15631547
final boolean isTableView)
15641548
throws MetadataException {
1565-
final TsTable originalTable =
1566-
clusterSchemaInfo.getTableForModification(
1567-
database,
1568-
tableName,
1569-
columnSchemaList.stream()
1570-
.map(TsTableColumnSchema::getColumnName)
1571-
.toArray(String[]::new));
1549+
final TsTable originalTable = getTableIfExists(database, tableName).orElse(null);
15721550

15731551
if (Objects.isNull(originalTable)) {
15741552
return new Pair<>(
@@ -1623,7 +1601,7 @@ public synchronized Pair<TSStatus, TsTable> tableColumnCheckForColumnAltering(
16231601
final TSDataType dataType,
16241602
final boolean isGeneratedByPipe)
16251603
throws MetadataException {
1626-
final TsTable originalTable = clusterSchemaInfo.getTableForModification(database, tableName);
1604+
final TsTable originalTable = getTableIfExists(database, tableName).orElse(null);
16271605

16281606
if (Objects.isNull(originalTable)) {
16291607
return new Pair<>(
@@ -1660,8 +1638,7 @@ public synchronized Pair<TSStatus, TsTable> tableColumnCheckForColumnRenaming(
16601638
final String newName,
16611639
final boolean isTableView)
16621640
throws MetadataException {
1663-
final TsTable originalTable =
1664-
clusterSchemaInfo.getTableForModification(database, tableName, oldName, newName);
1641+
final TsTable originalTable = getTableIfExists(database, tableName).orElse(null);
16651642

16661643
if (Objects.isNull(originalTable)) {
16671644
return new Pair<>(
@@ -1714,7 +1691,7 @@ public synchronized Pair<TSStatus, TsTable> tableCheckForRenaming(
17141691
final String newName,
17151692
final boolean isTableView)
17161693
throws MetadataException {
1717-
final TsTable originalTable = clusterSchemaInfo.getTableForModification(database, tableName);
1694+
final TsTable originalTable = getTableIfExists(database, tableName).orElse(null);
17181695

17191696
if (Objects.isNull(originalTable)) {
17201697
return new Pair<>(
@@ -1730,12 +1707,7 @@ public synchronized Pair<TSStatus, TsTable> tableCheckForRenaming(
17301707
return result.get();
17311708
}
17321709

1733-
final Optional<Pair<TsTable, TableNodeStatus>> targetTable =
1734-
getTableAndStatusIfExists(database, newName);
1735-
if (targetTable.isPresent() && targetTable.get().getRight() == TableNodeStatus.PRE_DELETE) {
1736-
throw new TableInDeletionException(database, newName);
1737-
}
1738-
if (targetTable.isPresent()) {
1710+
if (getTableIfExists(database, newName).isPresent()) {
17391711
return new Pair<>(
17401712
RpcUtils.getStatus(
17411713
TSStatusCode.TABLE_ALREADY_EXISTS,
@@ -1804,7 +1776,7 @@ public synchronized Pair<TSStatus, TsTable> updateTableProperties(
18041776
final Map<String, String> updatedProperties,
18051777
final boolean isTableView)
18061778
throws MetadataException {
1807-
final TsTable originalTable = clusterSchemaInfo.getTableForModification(database, tableName);
1779+
final TsTable originalTable = getTableIfExists(database, tableName).orElse(null);
18081780

18091781
if (Objects.isNull(originalTable)) {
18101782
return new Pair<>(

‎iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@
134134
import org.apache.iotdb.confignode.consensus.request.write.table.RenameTableColumnPlan;
135135
import org.apache.iotdb.confignode.consensus.request.write.table.RenameTablePlan;
136136
import org.apache.iotdb.confignode.consensus.request.write.table.RollbackCreateTablePlan;
137-
import org.apache.iotdb.confignode.consensus.request.write.table.RollbackPreAlterColumnDataTypePlan;
138137
import org.apache.iotdb.confignode.consensus.request.write.table.RollbackPreDeleteTablePlan;
139138
import org.apache.iotdb.confignode.consensus.request.write.table.SetTableColumnCommentPlan;
140139
import org.apache.iotdb.confignode.consensus.request.write.table.SetTableCommentPlan;
@@ -616,9 +615,6 @@ public TSStatus executeNonQueryPlan(ConfigPhysicalPlan physicalPlan)
616615
return clusterSchemaInfo.dropTable((CommitDeleteTablePlan) physicalPlan);
617616
case PreAlterColumnDataType:
618617
return clusterSchemaInfo.preAlterColumnDataType((PreAlterColumnDataTypePlan) physicalPlan);
619-
case RollbackPreAlterColumnDataType:
620-
return clusterSchemaInfo.rollbackPreAlterColumnDataType(
621-
(RollbackPreAlterColumnDataTypePlan) physicalPlan);
622618
case AlterColumnDataType:
623619
return clusterSchemaInfo.commitAlterColumnDataType(
624620
((AlterColumnDataTypePlan) physicalPlan));

‎iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java‎

Lines changed: 2 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@
2727
import org.apache.iotdb.commons.exception.IllegalPathException;
2828
import org.apache.iotdb.commons.exception.MetadataException;
2929
import org.apache.iotdb.commons.exception.SemanticException;
30-
import org.apache.iotdb.commons.exception.table.ColumnInAlterException;
31-
import org.apache.iotdb.commons.exception.table.ColumnInDeletionException;
32-
import org.apache.iotdb.commons.exception.table.TableInDeletionException;
3330
import org.apache.iotdb.commons.path.PartialPath;
3431
import org.apache.iotdb.commons.path.PathPatternTree;
3532
import org.apache.iotdb.commons.schema.table.TableNodeStatus;
3633
import org.apache.iotdb.commons.schema.table.TableType;
3734
import org.apache.iotdb.commons.schema.table.TreeViewSchema;
3835
import org.apache.iotdb.commons.schema.table.TsTable;
3936
import org.apache.iotdb.commons.schema.table.TsTableInternalRPCUtil;
40-
import org.apache.iotdb.commons.schema.table.column.TsTableColumnSchema;
4137
import org.apache.iotdb.commons.schema.template.Template;
4238
import org.apache.iotdb.commons.snapshot.SnapshotProcessor;
4339
import org.apache.iotdb.commons.utils.PathUtils;
@@ -71,7 +67,6 @@
7167
import org.apache.iotdb.confignode.consensus.request.write.table.RenameTableColumnPlan;
7268
import org.apache.iotdb.confignode.consensus.request.write.table.RenameTablePlan;
7369
import org.apache.iotdb.confignode.consensus.request.write.table.RollbackCreateTablePlan;
74-
import org.apache.iotdb.confignode.consensus.request.write.table.RollbackPreAlterColumnDataTypePlan;
7570
import org.apache.iotdb.confignode.consensus.request.write.table.RollbackPreDeleteTablePlan;
7671
import org.apache.iotdb.confignode.consensus.request.write.table.SetTableColumnCommentPlan;
7772
import org.apache.iotdb.confignode.consensus.request.write.table.SetTableCommentPlan;
@@ -114,7 +109,6 @@
114109
import org.apache.iotdb.rpc.TSStatusCode;
115110

116111
import org.apache.tsfile.annotations.TableModel;
117-
import org.apache.tsfile.enums.TSDataType;
118112
import org.apache.tsfile.utils.Pair;
119113
import org.slf4j.Logger;
120114
import org.slf4j.LoggerFactory;
@@ -1358,11 +1352,9 @@ public ShowTableResp showTables(final ShowTablePlan plan) {
13581352
})
13591353
.collect(Collectors.toList())
13601354
: tableModelMTree
1361-
.getAllTablesUnderSpecificDatabase(
1355+
.getAllUsingTablesUnderSpecificDatabase(
13621356
getQualifiedDatabasePartialPath(plan.getDatabase()))
13631357
.stream()
1364-
.filter(pair -> pair.getRight() != TableNodeStatus.PRE_CREATE)
1365-
.map(Pair::getLeft)
13661358
.map(
13671359
tsTable ->
13681360
new TTableInfo(
@@ -1455,7 +1447,7 @@ public DescTableResp descTable(final DescTablePlan plan) {
14551447
}
14561448
return new DescTableResp(
14571449
StatusUtils.OK,
1458-
tableModelMTree.getTableSchemaForDesc(databasePath, plan.getTableName()),
1450+
tableModelMTree.getUsingTableSchema(databasePath, plan.getTableName()),
14591451
null,
14601452
null);
14611453
} catch (final MetadataException e) {
@@ -1565,80 +1557,6 @@ public Optional<Pair<TsTable, TableNodeStatus>> getTsTableIfExists(
15651557
}
15661558
}
15671559

1568-
public TsTable getTableForModification(
1569-
final String database, final String tableName, final String... columnNames)
1570-
throws MetadataException {
1571-
databaseReadWriteLock.readLock().lock();
1572-
try {
1573-
final PartialPath databasePath = getQualifiedDatabasePartialPath(database);
1574-
final Optional<Pair<TsTable, TableNodeStatus>> tableAndStatus =
1575-
tableModelMTree.getTableAndStatusIfExists(databasePath, tableName);
1576-
if (!tableAndStatus.isPresent()) {
1577-
return null;
1578-
}
1579-
if (tableAndStatus.get().getRight() == TableNodeStatus.PRE_DELETE) {
1580-
throw new TableInDeletionException(database, tableName);
1581-
}
1582-
final TableSchemaDetails details =
1583-
tableModelMTree.getTableSchemaDetails(databasePath, tableName);
1584-
for (final String columnName : columnNames) {
1585-
if (details.preDeletedColumns.contains(columnName)) {
1586-
throw new ColumnInDeletionException(database, tableName, columnName);
1587-
}
1588-
if (details.preAlteredColumns.containsKey(columnName)) {
1589-
throw new ColumnInAlterException(database, tableName, columnName);
1590-
}
1591-
}
1592-
return tableModelMTree.getTableSchemaForDataNode(databasePath, tableName);
1593-
} finally {
1594-
databaseReadWriteLock.readLock().unlock();
1595-
}
1596-
}
1597-
1598-
public boolean isColumnAlterCommitted(
1599-
final String database,
1600-
final String tableName,
1601-
final String columnName,
1602-
final TSDataType dataType)
1603-
throws MetadataException {
1604-
databaseReadWriteLock.readLock().lock();
1605-
try {
1606-
final PartialPath databasePath = getQualifiedDatabasePartialPath(database);
1607-
final Optional<Pair<TsTable, TableNodeStatus>> tableAndStatus =
1608-
tableModelMTree.getTableAndStatusIfExists(databasePath, tableName);
1609-
if (!tableAndStatus.isPresent()) {
1610-
return false;
1611-
}
1612-
final TableSchemaDetails details =
1613-
tableModelMTree.getTableSchemaDetails(databasePath, tableName);
1614-
final TsTableColumnSchema columnSchema = details.table.getColumnSchema(columnName);
1615-
return !details.preAlteredColumns.containsKey(columnName)
1616-
&& columnSchema != null
1617-
&& columnSchema.getDataType() == dataType;
1618-
} finally {
1619-
databaseReadWriteLock.readLock().unlock();
1620-
}
1621-
}
1622-
1623-
public Optional<TSDataType> getPreAlteredColumnType(
1624-
final String database, final String tableName, final String columnName)
1625-
throws MetadataException {
1626-
databaseReadWriteLock.readLock().lock();
1627-
try {
1628-
final PartialPath databasePath = getQualifiedDatabasePartialPath(database);
1629-
if (!tableModelMTree.getTableAndStatusIfExists(databasePath, tableName).isPresent()) {
1630-
return Optional.empty();
1631-
}
1632-
return Optional.ofNullable(
1633-
tableModelMTree
1634-
.getTableSchemaDetails(databasePath, tableName)
1635-
.preAlteredColumns
1636-
.get(columnName));
1637-
} finally {
1638-
databaseReadWriteLock.readLock().unlock();
1639-
}
1640-
}
1641-
16421560
public TSStatus addTableColumn(final AddTableColumnPlan plan) {
16431561
return executeWithLock(
16441562
() -> {
@@ -1726,23 +1644,6 @@ public TSStatus preAlterColumnDataType(final PreAlterColumnDataTypePlan plan) {
17261644
}
17271645
}
17281646

1729-
public TSStatus rollbackPreAlterColumnDataType(final RollbackPreAlterColumnDataTypePlan plan) {
1730-
databaseReadWriteLock.writeLock().lock();
1731-
try {
1732-
tableModelMTree.rollbackPreAlterColumnDataType(
1733-
getQualifiedDatabasePartialPath(plan.getDatabase()),
1734-
plan.getTableName(),
1735-
plan.getColumnName(),
1736-
plan.getNewType());
1737-
return RpcUtils.SUCCESS_STATUS;
1738-
} catch (final MetadataException e) {
1739-
LOGGER.warn(e.getMessage(), e);
1740-
return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
1741-
} finally {
1742-
databaseReadWriteLock.writeLock().unlock();
1743-
}
1744-
}
1745-
17461647
public TSStatus commitAlterColumnDataType(AlterColumnDataTypePlan plan) {
17471648
databaseReadWriteLock.writeLock().lock();
17481649
try {

0 commit comments

Comments
 (0)