Skip to content
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

TiFlash panics with Data type Nullable(Nothing) cannot be used in tables while syncing expression index schema ((null)) #9891

Open
solotzg opened this issue Feb 19, 2025 · 1 comment
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. component/storage impact/panic report/customer Customers have encountered this bug. severity/moderate type/bug The issue is confirmed as a bug.

Comments

@solotzg
Copy link
Contributor

solotzg commented Feb 19, 2025

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `t` (
  `id` int,
  KEY `idx_name` ((null))
);
alter table t set tiflash replica 1;
insert t values(0);

2. What did you expect to see? (Required)

3. What did you see instead (Required)

tiflash panics;

error logs:

Code: 370, e.displayText() = DB::Exception: Data type Nullable(Nothing) cannot be used in tables

4. What is your TiFlash version? (Required)

>= v6.1.0

@solotzg solotzg added affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. severity/minor type/bug The issue is confirmed as a bug. labels Feb 19, 2025
@ti-chi-bot ti-chi-bot bot added the report/customer Customers have encountered this bug. label Feb 19, 2025
@JaySon-Huang
Copy link
Contributor

The logging when reproduce. Seems that the expression index KEY idx_name ((null)) will create a column with "Tp": 6

{
	"cols": [{
		"id": 1,
		"name": {
			"L": "id",
			"O": "id"
		},
		"offset": 0,
		"state": 5,
		"type": {
			"Charset": "binary",
			"Collate": "binary",
			"Decimal": 0,
			"Flag": 0,
			"Flen": 11,
			"Tp": 3
		}
	}, {
		"id": 2,
		"name": {
			"L": "_v$_idx_name_0",
			"O": "_v$_idx_name_0"
		},
		"offset": 1,
		"state": 5,
		"type": {
			"Charset": "binary",
			"Collate": "binary",
			"Decimal": 0,
			"Flag": 136,
			"Flen": 0,
			"Tp": 6
		}
	}],
	"id": 242807,
	"index_info": [],
	"is_common_handle": false,
	"keyspace_id": 4294967295,
	"name": {
		"L": "t",
		"O": "t"
	},
	"pk_is_handle": false,
	"schema_version": -1,
	"state": 5,
	"tiflash_replica": {
		"Available": false,
		"Count": 1
	},
	"update_timestamp": 456163970651521027
}
[2025/02/21 16:44:11.911 +08:00] [INFO] [SchemaBuilder.cpp:1159] ["Create table db_2.t (database_id=2 table_id=242807) with statement: CREATE TABLE `db_2`.`t_242807`(`id` Nullable(Int32), `_v$_idx_name_0` Nullable(Nothing), `_tidb_rowid` Int64) Engine = DeltaMerge((`_tidb_rowid`), '{\"cols\":[{\"id\":1,\"name\":{\"L\":\"id\",\"O\":\"id\"},\"offset\":0,\"state\":5,\"type\":{\"Charset\":\"binary\",\"Collate\":\"binary\",\"Decimal\":0,\"Flag\":0,\"Flen\":11,\"Tp\":3}},{\"id\":2,\"name\":{\"L\":\"_v$_idx_name_0\",\"O\":\"_v$_idx_name_0\"},\"offset\":1,\"state\":5,\"type\":{\"Charset\":\"binary\",\"Collate\":\"binary\",\"Decimal\":0,\"Flag\":136,\"Flen\":0,\"Tp\":6}}],\"id\":242807,\"index_info\":[],\"is_common_handle\":false,\"keyspace_id\":4294967295,\"name\":{\"L\":\"t\",\"O\":\"t\"},\"pk_is_handle\":false,\"schema_version\":-1,\"state\":5,\"tiflash_replica\":{\"Available\":false,\"Count\":1},\"update_timestamp\":456163970651521027}', 0)"] [source="keyspace=4294967295"] [thread_id=9166]
[2025/02/21 16:44:11.915 +08:00] [ERROR] [RaftCommands.cpp:506] ["[region_id=423019 applied_term=6 applied_index=8] catch exception: Data type Nullable(Nothing) cannot be used in tables, while applying `RegionTable::writeCommittedByRegion` on [term 6, index 9], entries PUT|write|74800000000003B4FF775F728000000000FF0000010000000000FAF9AB614916DBFFF5:DEL|lock|74800000000003B4FF775F728000000000FF0000010000000000FA"] [thread_id=9166]
[2025/02/21 16:44:14.558 +08:00] [INFO] [TiDBSchemaSyncer.cpp:96] ["Start to sync schemas. current version is: 181853 and try to sync schema version to: 181854"] [source="keyspace=4294967295"] [thread_id=9167]
[2025/02/21 16:44:14.559 +08:00] [INFO] [TiDBSchemaSyncer.cpp:129] ["End sync schema, version has been updated to 181854"] [source="keyspace=4294967295"] [thread_id=9167]
[2025/02/21 16:44:18.623 +08:00] [FATAL] [Exception.cpp:106] ["Code: 370, e.displayText() = DB::Exception: Data type Nullable(Nothing) cannot be used in tables, e.what() = DB::Exception, Stack trace:
  0x55d0187f5fc3    DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int) [tiflash+33767363]
                    dbms/src/Common/StackTrace.cpp:23
  0x55d01ea61799    DB::StorageFactory::get(DB::ASTCreateQuery&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, DB::Context&, DB::Context&, DB::ColumnsDescription const&, bool, bool) const [tiflash+136968089]
                    dbms/src/Storages/StorageFactory.cpp:43
  0x55d01e2da6c5    DB::InterpreterCreateQuery::createTable(DB::ASTCreateQuery&) [tiflash+129074885]
                    dbms/src/Interpreters/InterpreterCreateQuery.cpp:654
  0x55d01e2dc403    DB::InterpreterCreateQuery::execute() [tiflash+129082371]
                    dbms/src/Interpreters/InterpreterCreateQuery.cpp:719
  0x55d01efc5cd5    DB::SchemaBuilder<DB::SchemaGetter, DB::SchemaNameMapper>::applyCreateStorageInstance(long, std::__1::shared_ptr<TiDB::TableInfo> const&, bool, std::__1::basic_string_view<char, std::__1::char_traits<char>>) [tiflash+142621909]
                    dbms/src/TiDB/Schema/SchemaBuilder.cpp:1186
  0x55d01efc4be2    DB::SchemaBuilder<DB::SchemaGetter, DB::SchemaNameMapper>::applyTable(long, long, long, bool) [tiflash+142617570]
                    dbms/src/TiDB/Schema/SchemaBuilder.cpp:1694
  0x55d018736d2f    DB::TiDBSchemaSyncer<false, false>::trySyncTableSchema(DB::Context&, long, DB::SchemaGetter&, bool, char const*) [tiflash+32984367]
                    dbms/src/TiDB/Schema/TiDBSchemaSyncer.cpp:237
  0x55d01873680f    DB::TiDBSchemaSyncer<false, false>::syncTableSchema(DB::Context&, long) [tiflash+32983055]
                    dbms/src/TiDB/Schema/TiDBSchemaSyncer.cpp:282
  0x55d01f72b79e    std::__1::optional<DB::DM::RaftWriteResult> DB::writeRegionDataToStorage<std::__1::vector<DB::RegionDataReadInfo, std::__1::allocator<DB::RegionDataReadInfo>>>(DB::Context&, DB::RegionPtrWithBlock const&, std::__1::vector<DB::RegionDataReadInfo, std::__1::allocator<DB::RegionDataReadInfo>>&, std::__1::shared_ptr<DB::Logger> const&) [tiflash+150378398]
                    dbms/src/TiDB/Schema/TiDBSchemaManager.h:41
  0x55d01f72b149    DB::RegionTable::writeCommittedByRegion(DB::Context&, DB::RegionPtrWithBlock const&, std::__1::vector<DB::RegionDataReadInfo, std::__1::allocator<DB::RegionDataReadInfo>>&, std::__1::shared_ptr<DB::Logger> const&, bool) [tiflash+150376777]
                    dbms/src/Storages/KVStore/Decode/PartitionStreams.cpp:455
  0x55d01f69cd31    DB::Region::handleWriteRaftCmd(DB::WriteCmdsView const&, unsigned long, unsigned long, DB::TMTContext&) [tiflash+149794097]
                    dbms/src/Storages/KVStore/MultiRaft/RaftCommands.cpp:481
  0x55d01f6a3db7    DB::KVStore::handleWriteRaftCmdInner(DB::WriteCmdsView const&, unsigned long, unsigned long, unsigned long, DB::TMTContext&, std::__1::optional<DB::DM::RaftWriteResult>&) [tiflash+149822903]
                    dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp:62
  0x55d01f6a3c24    DB::KVStore::handleWriteRaftCmd(DB::WriteCmdsView const&, unsigned long, unsigned long, unsigned long, DB::TMTContext&) [tiflash+149822500]
                    dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp:41
  0x55d01f634295    HandleWriteRaftCmd [tiflash+149365397]
                    dbms/src/Storages/KVStore/FFI/ProxyFFI.cpp:98
  0x7fa89d67b3d9    _$LT$engine_store_ffi..observer..TiFlashObserver$LT$T$C$ER$GT$$u20$as$u20$raftstore..coprocessor..QueryObserver$GT$::post_exec_query::h2bfc19cc0e7327b6 [libtiflash_proxy.so+65536985]
                    contrib/tiflash-proxy/proxy_components/engine_store_ffi/src/observer.rs:155
  0x7fa89e95b70d    raftstore::store::fsm::apply::ApplyDelegate$LT$EK$GT$::apply_raft_cmd::hd493405c5411d745 [libtiflash_proxy.so+85329677]
                    contrib/tiflash-proxy/components/raftstore/src/store/fsm/apply.rs:1554
  0x7fa89e96e5fe    raftstore::store::fsm::apply::ApplyDelegate$LT$EK$GT$::process_raft_cmd::h4ae607d31514f110 [libtiflash_proxy.so+85407230]
                    contrib/tiflash-proxy/components/raftstore/src/store/fsm/apply.rs:1421
  0x7fa89e970fbc    raftstore::store::fsm::apply::ApplyDelegate$LT$EK$GT$::handle_raft_committed_entries::h44eecdf9f92e6441 [libtiflash_proxy.so+85417916]
                    contrib/tiflash-proxy/components/raftstore/src/store/fsm/apply.rs:1171
  0x7fa89e94ac9d    raftstore::store::fsm::apply::ApplyFsm$LT$EK$GT$::handle_apply::h83d4543fd1f1d463 [libtiflash_proxy.so+85261469]
                    contrib/tiflash-proxy/components/raftstore/src/store/fsm/apply.rs:4104
  0x7fa89e94f0e4    raftstore::store::fsm::apply::ApplyFsm$LT$EK$GT$::handle_tasks::hc8c95bd9cecd8cf5 [libtiflash_proxy.so+85278948]
                    contrib/tiflash-proxy/components/raftstore/src/store/fsm/apply.rs:4458
  0x7fa89d7f8778    _$LT$raftstore..store..fsm..apply..ApplyPoller$LT$EK$GT$$u20$as$u20$batch_system..batch..PollHandler$LT$raftstore..store..fsm..apply..ApplyFsm$LT$EK$GT$$C$raftstore..store..fsm..apply..ControlFsm$GT$$GT$::handle_normal::h7d1441b386a73ed6 [libtiflash_proxy.so+67098488]
                    contrib/tiflash-proxy/components/raftstore/src/store/fsm/apply.rs:4757
  0x7fa89d718236    batch_system::batch::Poller$LT$N$C$C$C$Handler$GT$::poll::hb5e9e1b5bdba67e8 [libtiflash_proxy.so+66179638]
                    contrib/tiflash-proxy/components/batch-system/src/batch.rs:380
  0x7fa89d859e2f    std::sys_common::backtrace::__rust_begin_short_backtrace::h0677a1377ca82aa0 [libtiflash_proxy.so+67497519]
                    /rustc/89e2160c4ca5808657ed55392620ed1dbbce78d1/library/std/src/sys_common/backtrace.rs:155
  0x7fa89d8c2589    core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::ha68390a2fed0b7e0 [libtiflash_proxy.so+67925385]
                    /rustc/89e2160c4ca5808657ed55392620ed1dbbce78d1/library/core/src/ops/function.rs:250
  0x7fa89f282b56    std::sys::unix::thread::Thread::new::thread_start::hd01330a228cdd35d [libtiflash_proxy.so+94927702]
                    /rustc/89e2160c4ca5808657ed55392620ed1dbbce78d1/library/std/src/sys/unix/thread.rs:108
  0x7fa8994aec02    start_thread [libc.so.6+564226]
  0x7fa899533c40    clone3 [libc.so.6+1109056]"] [source="EngineStoreApplyRes DB::HandleWriteRaftCmd(const EngineStoreServerWrap *, WriteCmdsView, RaftCmdHeader)"] [thread_id=9166]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. component/storage impact/panic report/customer Customers have encountered this bug. severity/moderate type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

3 participants