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

Failed to parse TiDB schema with binary default value #9461

Closed
Lloyd-Pottiger opened this issue Sep 23, 2024 · 1 comment · Fixed by #9467
Closed

Failed to parse TiDB schema with binary default value #9461

Lloyd-Pottiger opened this issue Sep 23, 2024 · 1 comment · Fixed by #9467
Assignees
Labels
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. component/storage severity/major type/bug The issue is confirmed as a bug.

Comments

@Lloyd-Pottiger
Copy link
Contributor

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

@Lloyd-Pottiger Lloyd-Pottiger added the type/bug The issue is confirmed as a bug. label Sep 23, 2024
@Lloyd-Pottiger
Copy link
Contributor Author

TEST(JSONParser, TestUnicode)
try
{
    String json_str = R"json({"default":"\u0007\u0007"})json";
    Poco::JSON::Parser parser;
    Poco::Dynamic::Var result = parser.parse(json_str);
    const auto & obj = result.extract<Poco::JSON::Object::Ptr>();
    auto default_val = obj->get("default");
    Poco::JSON::Object::Ptr json = new Poco::JSON::Object();
    json->set("default", default_val);
    std::stringstream ss;
    json->stringify(ss);
    std::cout << ss.str() << std::endl;
    ASSERT_TRUE(ss.str() == json_str);
}
CATCH

@Lloyd-Pottiger Lloyd-Pottiger 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. and removed may-affects-5.4 may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 may-affects-8.1 labels Sep 23, 2024
@Lloyd-Pottiger Lloyd-Pottiger self-assigned this Sep 23, 2024
@ti-chi-bot ti-chi-bot bot closed this as completed in 1ce2f11 Sep 26, 2024
ti-chi-bot bot pushed a commit that referenced this issue Sep 27, 2024
close #9461

ddl: fix TypeBit default value

Signed-off-by: JaySon-Huang <tshent@qq.com>

Co-authored-by: JaySon-Huang <tshent@qq.com>
ti-chi-bot bot pushed a commit that referenced this issue Sep 30, 2024
close #9461

ddl: fix TypeBit default value

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

Co-authored-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Co-authored-by: JaySon-Huang <tshent@qq.com>
@Lloyd-Pottiger Lloyd-Pottiger 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. and removed 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. labels Sep 30, 2024
@Lloyd-Pottiger Lloyd-Pottiger removed affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. labels Nov 1, 2024
ti-chi-bot bot pushed a commit that referenced this issue Nov 4, 2024
close #9461

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. component/storage severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant