Skip to content

Failed to parse TiDB schema with binary default value #9461

Closed
@Lloyd-Pottiger

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> CREATE TABLE t (`col` bit(12) DEFAULT b'11100000111');
mysql> alter table t set tiflash replica 1;

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

No error in TiFlash

3. What did you see instead (Required)

Error log like

[2024/09/19 16:38:21.194 +08:00] [FATAL] [Exception.cpp:106] ["Code: 0, e.displayText() = DB::Exception: void TiDB::TableInfo::deserialize(const DB::String &): Parse TiDB schema JSON failed (TableInfo): JSON Exception: error: 1: bad escaped byte, 'a', json: {\"belonging_table_id\":-1,\"cols\":[{\"default\":null,\"default_bit\":null,\"id\":1,\"name\":{\"L\":\"col_86\",\"O\":\"col_86\"},\"offset\":0,\"origin_default\":null,\"state\":5,\"type\":{\"Charset\":\"binary\",\"Collate\":\"binary\",\"Decimal\":0,\"Elems\":null,\"Flag\":128,\"Flen\":65535,\"Tp\":252}},{\"default\":\"1994-05-06 00:00:00\",\"default_bit\":null,\"id\":2,\"name\":{\"L\":\"col_87\",\"O\":\"col_87\"},\"offset\":1,\"origin_default\":null,\"state\":5,\"type\":{\"Charset\":\"binary\",\"Collate\":\"binary\",\"Decimal\":0,\"Elems\":null,\"Flag\":129,\"Flen\":19,\"Tp\":12}},{\"default\":null,\"default_bit\":null,\"id\":3,\"name\":{\"L\":\"col_88\",\"O\":\"col_88\"},\"offset\":2,\"origin_default\":null,\"state\":5,\"type\":{\"Charset\":\"binary\",\"Collate\":\"binary\",\"Decimal\":0,\"Elems\":null,\"Flag\":32,\"Flen\":42,\"Tp\":16}},{\"default\":\"\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\",\"default_bit\":null,\"id\":4,\"name\":{\"L\":\"col_89\",\"O\":\"col_89\"},\"offset\":3,\"origin_default\":null,\"state\":5,\"type\":{\"Charset\":\"binary\",\"Collate\":\"binary\",\"Decimal\":0,\"Elems\":null,\"Flag\":129,\"Flen\":21,\"Tp\":254}},{\"default\":null,\"default_bit\":null,\"id\":5,\"name\":{\"L\":\"col_90\",\"O\":\"col_90\"},\"offset\":4,\"origin_default\":null,\"state\":5,\"type\":{\"Charset\":\"binary\",\"Collate\":\"binary\",\"Decimal\":0,\"Elems\":null,\"Flag\":4129,\"Flen\":3,\"Tp\":1}},{\"default\":\"\\a\\a\",\"default_bit\":\"Bwc=\",\"id\":6,\"name\":{\"L\":\"col_91\",\"O\":\"col_91\"},\"offset\":5,\"origin_default\":null,\"state\":5,\"type\":{\"Charset\":\"binary\",\"Collate\":\"binary\",\"Decimal\":0,\"Elems\":null,\"Flag\":32,\"Flen\":12,\"Tp\":16}},{\"default\":\"kY~6to6H4ut*QAPrj@&\",\"default_bit\":null,\"id\":7,\"name\":{\"L\":\"col_92\",\"O\":\"col_92\"},\"offset\":6,\"origin_default\":null,\"state\":5,\"type\":{\"Charset\":\"binary\",\"Collate\":\"binary\",\"Decimal\":0,\"Elems\":null,\"Flag\":129,\"Flen\":343,\"Tp\":15}},{\"default\":null,\"default_bit\":null,\"id\":8,\"name\":{\"L\":\"col_93\",\"O\":\"col_93\"},\"offset\":7,\"origin_default\":null,\"state\":5,\"type\":{\"Charset\":\"binary\",\"Collate\":\"binary\",\"Decimal\":0,\"Elems\":null,\"Flag\":128,\"Flen\":-1,\"Tp\":245}}],\"id\":546,\"index_info\":[],\"is_common_handle\":false,\"keyspace_id\":4294967295,\"name\":{\"L\":\"tcfc7825f\",\"O\":\"tcfc7825f\"},\"partition\":{\"definitions\":[{\"id\":547,\"name\":{\"L\":\"p0\",\"O\":\"p0\"}},{\"id\":548,\"name\":{\"L\":\"p1\",\"O\":\"p1\"}},{\"id\":549,\"name\":{\"L\":\"p2\",\"O\":\"p2\"}}],\"enable\":true,\"expr\":\"`col_90`\",\"num\":3,\"type\":1},\"pk_is_handle\":false,\"schema_version\":-1,\"state\":5,\"tiflash_replica\":{\"Count\":0},\"update_timestamp\":452653246119673943}: keyspace=4294967295 physical_table_id=209: (while preHandleSnapshot region_id=729, index=7, term=6), e.what() = DB::Exception, Stack trace:\n\n\n     0x10244cf88\tStackTrace::StackTrace() [tiflash+4295380872]\n     0x1024c79b0\tDB::Exception::Exception(Poco::Exception const&) [tiflash+4295883184]\n     0x108609310\tTiDB::TableInfo::deserialize(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) [tiflash+4397863696]\n     0x107520638\tstd::__1::__function::__func<DB::registerStorageDeltaMerge(DB::StorageFactory&)::$_0, std::__1::allocator<DB::registerStorageDeltaMerge(DB::StorageFactory&)::$_0>, std::__1::shared_ptr<DB::IStorage> (DB::StorageFactory::Arguments const&)>::operator()(DB::StorageFactory::Arguments const&) [tiflash+4380132920]\n     0x1084ed004\tDB::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+4396699652]\n     0x108046f64\tDB::InterpreterCreateQuery::createTable(DB::ASTCreateQuery&) [tiflash+4391825252]\n     0x1085b5274\tDB::SchemaBuilder<DB::SchemaGetter, DB::SchemaNameMapper>::applyCreateStorageInstance(long long, std::__1::shared_ptr<TiDB::TableInfo> const&, bool, std::__1::basic_string_view<char, std::__1::char_traits<char>>) [tiflash+4397519476]\n     0x1085ad89c\tDB::SchemaBuilder<DB::SchemaGetter, DB::SchemaNameMapper>::applyCreateTable(long long, long long, std::__1::basic_string_view<char, std::__1::char_traits<char>>) [tiflash+4397488284]\n     0x1085ac258\tDB::SchemaBuilder<DB::SchemaGetter, DB::SchemaNameMapper>::applyDiff(DB::SchemaDiff const&) [tiflash+4397482584]\n     0x108612d0c\tDB::TiDBSchemaSyncer<false, false>::syncSchemaDiffs(DB::Context&, DB::SchemaGetter&, long long) [tiflash+4397903116]\n     0x1086118ac\tDB::TiDBSchemaSyncer<false, false>::syncSchemasByGetter(DB::Context&, DB::SchemaGetter&) [tiflash+4397897900]\n     0x108611f2c\tDB::TiDBSchemaSyncer<false, false>::syncTableSchema(DB::Context&, long long) [tiflash+4397899564]\n     0x108b12adc\tDB::AtomicGetStorageSchema(unsigned long long, unsigned int, long long, DB::TMTContext&) [tiflash+4403145436]\n     0x108a8e07c\tDB::KVStore::preHandleSSTsToDTFiles(std::__1::shared_ptr<DB::Region>, DB::SSTViewVec, unsigned long long, unsigned long long, DB::DM::FileConvertJobType, DB::TMTContext&) [tiflash+4402602108]\n     0x108a8dcd4\tDB::KVStore::preHandleSnapshotToFiles(std::__1::shared_ptr<DB::Region>, DB::SSTViewVec, unsigned long long, unsigned long long, std::__1::optional<unsigned long long>, DB::TMTContext&) [tiflash+4402601172]\n     0x108a67490\t_PreHandleSnapshot [tiflash+4402443408]\n     0x118fc3aa8\tproxy_ffi::engine_store_helper_impls::_$LT$impl$u20$proxy_ffi..interfaces..root..DB..EngineStoreServerHelper$GT$::pre_handle_snapshot::hd43b10cd69cbdf65 [libtiflash_proxy.dylib+7453352]\n     0x118b9ef18\tengine_store_ffi::core::forward_raft::snapshot::pre_handle_snapshot_impl::heea8b527627de424 [libtiflash_proxy.dylib+3108632]\n     0x11982c75c\tyatp::task::future::RawTask$LT$F$GT$::poll::h38f48651974eb3a5 [libtiflash_proxy.dylib+16271196]\n     0x11b0282b8\t_$LT$yatp..task..future..Runner$u20$as$u20$yatp..pool..runner..Runner$GT$::handle::h6623ab9022885b7b [libtiflash_proxy.dylib+41419448]\n     0x11b017cf4\tstd::sys_common::backtrace::__rust_begin_short_backtrace::h1368bc2622ceb6ec [libtiflash_proxy.dylib+41352436]\n     0x11b01ad04\tcore::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::he5e291aaa71bf595 [libtiflash_proxy.dylib+41364740]\n     0x11a7eb2dc\tstd::sys::unix::thread::Thread::new::thread_start::hdb3bea64af965bb9 [libtiflash_proxy.dylib+32781020]\n     0x18d6b6034\t__pthread_joiner_wake [libsystem_pthread.dylib+6446899252]\n     0x18d6b0e3c\t__pthread_mutex_global_init [libsystem_pthread.dylib+6446878268]"] [source="DB::RawCppPtr DB::PreHandleSnapshot(DB::EngineStoreServerWrap *, DB::BaseBuffView, uint64_t, DB::SSTViewVec, uint64_t, uint64_t)"] [thread_id=68]

4. What is your TiFlash version? (Required)

master

Metadata

Labels

affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.component/storageseverity/majortype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions