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

Invalid default value of Decimal column under NOT strict sql mode may make TiFlash panic #8803

Closed
JinheLin opened this issue Feb 28, 2024 · 2 comments · Fixed by #8850
Closed
Assignees
Labels
affects-5.3 affects-5.4 This bug affects the 5.4.x(LTS) versions. 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.0 component/storage report/customer Customers have encountered this bug. severity/moderate type/bug The issue is confirmed as a bug.

Comments

@JinheLin
Copy link
Contributor

JinheLin commented Feb 28, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

set sql_mode='ansi';

create table t (a int);

alter table t set tiflash replica 1;

-- use an empty string as the default value for decimal column
alter table t add column d decimal(34, 2) default '';
alter table t add column d2 decimal(34, 2) default 'abcd';
show create table t\G
***************************[ 1. row ]***************************
Table        | t
Create Table | CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL,
  `d` decimal(34,2) DEFAULT '',
  `d2` decimal(34,2) DEFAULT 'abcd'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin

insert into t(a) values (1),(2),(3),(4);

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

TiFlash run normally.

set tidb_isolation_read_engines='tiflash';
select * from t;
+---+------+------+
| a | d    | d2   |
+---+------+------+
| 1 | 0.00 | 0.00 |
| 2 | 0.00 | 0.00 |
| 3 | 0.00 | 0.00 |
| 4 | 0.00 | 0.00 |
+---+------+------+

3. What did you see instead (Required)

TiFlash crashes repeatly.

[2024/02/27 12:12:14.666 +08:00] [ERROR] [Exception.cpp:89] ["Code: 32, e.displayText() = DB::Exception: Attempt to read after eof: physical_table_id=-1: (while preHandleSnapshot region_id=17143818, index=7, term=6), e.what() = DB::Exception, Stack trace:


       0x17385aa\tDB::throwReadAfterEOF() [tiflash+24348074]
                \tdbms/src/IO/VarInt.h:167
       0x6151a77\tvoid DB::readDecimalText<__int128>(DB::Decimal<__int128>&, DB::ReadBuffer&, unsigned int, unsigned int) [tiflash+102046327]
                \tdbms/src/IO/ReadHelpers.h:272
       0x6b37570\tTiDB::ColumnInfo::getDecimalValue(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const [tiflash+112424304]
                \tdbms/src/Storages/Transaction/TiDB.cpp:230
       0x6b3606d\tTiDB::ColumnInfo::defaultValueToField() const [tiflash+112418925]
                \tdbms/src/Storages/Transaction/TiDB.cpp:195
       0x6c07f4b\tDB::setAlterCommandColumn(Poco::Logger*, DB::AlterCommand&, TiDB::ColumnInfo const&) [tiflash+113278795]
                \tdbms/src/TiDB/Schema/SchemaBuilder.cpp:87
       0x6be7155\tDB::detectSchemaChanges(Poco::Logger*, TiDB::TableInfo const&, TiDB::TableInfo const&) [tiflash+113144149]
                \tdbms/src/TiDB/Schema/SchemaBuilder.cpp:307
       0x6be3781\tDB::SchemaBuilder<DB::SchemaGetter, DB::SchemaNameMapper>::applyAlterPhysicalTable(std::__1::shared_ptr<TiDB::DBInfo> const&, std::__1::shared_ptr<TiDB::TableInfo> const&, std::__1::shared_ptr<DB::IManageableStorage> const&) [tiflash+113129345]
                \tdbms/src/TiDB/Schema/SchemaBuilder.cpp:335
       0x6bdeb03\tDB::SchemaBuilder<DB::SchemaGetter, DB::SchemaNameMapper>::applyAlterLogicalTable(std::__1::shared_ptr<TiDB::DBInfo> const&, std::__1::shared_ptr<TiDB::TableInfo> const&, std::__1::shared_ptr<DB::IManageableStorage> const&) [tiflash+113109763]
                \tdbms/src/TiDB/Schema/SchemaBuilder.cpp:425
       0x6bdb135\tDB::SchemaBuilder<DB::SchemaGetter, DB::SchemaNameMapper>::syncAllSchema() [tiflash+113094965]
                \tdbms/src/TiDB/Schema/SchemaBuilder.cpp:1357
       0x6b22386\tDB::TiDBSchemaSyncer<false, false>::syncSchemas(DB::Context&) [tiflash+112337798]
                \tdbms/src/TiDB/Schema/TiDBSchemaSyncer.h:131
       0x6aba030\tDB::AtomicGetStorageSchema(std::__1::shared_ptr<DB::Region> const&, DB::TMTContext&) [tiflash+111910960]
                \tdbms/src/Storages/Transaction/PartitionStreams.cpp:530
       0x6a67640\tDB::KVStore::preHandleSSTsToDTFiles(std::__1::shared_ptr<DB::Region>, DB::SSTViewVec, unsigned long, unsigned long, DB::DM::FileConvertJobType, DB::TMTContext&) [tiflash+111572544]
                \tdbms/src/Storages/Transaction/ApplySnapshot.cpp:316
       0x6a67214\tDB::KVStore::preHandleSnapshotToFiles(std::__1::shared_ptr<DB::Region>, DB::SSTViewVec, unsigned long, unsigned long, DB::TMTContext&) [tiflash+111571476]
                \tdbms/src/Storages/Transaction/ApplySnapshot.cpp:275
       0x6ac2516\tPreHandleSnapshot [tiflash+111944982]
                \tdbms/src/Storages/Transaction/ProxyFFI.cpp:388
  0x7f70f66e9228\tengine_store_ffi::_$LT$impl$u20$engine_store_ffi..interfaces..root..DB..EngineStoreServerHelper$GT$::pre_handle_snapshot::hec57f9b0ef29a0bb [libtiflash_proxy.so+17646120]
  0x7f70f66e0d09\tengine_store_ffi::observer::pre_handle_snapshot_impl::h0b40090f59175b24 [libtiflash_proxy.so+17612041]
  0x7f70f66d3b86\tyatp::task::future::RawTask$LT$F$GT$::poll::hd3296fb5cae316b9 [libtiflash_proxy.so+17558406]
  0x7f70f855ff13\t_$LT$yatp..task..future..Runner$u20$as$u20$yatp..pool..runner..Runner$GT$::handle::h0056e31c4da70e35 [libtiflash_proxy.so+49590035]
  0x7f70f85527fc\tstd::sys_common::backtrace::__rust_begin_short_backtrace::h747afb2668c16dcb [libtiflash_proxy.so+49534972]
  0x7f70f855331c\tcore::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h83ec6721ad8db87f [libtiflash_proxy.so+49537820]
  0x7f70f7cc06a5\tstd::sys::unix::thread::Thread::new::thread_start::hd2791a9cabec1fda [libtiflash_proxy.so+40548005]
                \t/rustc/96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef/library/std/src/sys/unix/thread.rs:108
  0x7f70f5400ea5\tstart_thread [libpthread.so.0+32421]
  0x7f70f4805b0d\tclone [libc.so.6+1043213]"] [source="DB::RawCppPtr DB::PreHandleSnapshot(DB::EngineStoreServerWrap *, DB::BaseBuffView, uint64_t, DB::SSTViewVec, uint64_t, uint64_t)"] [thread_id=318]

4. What is your TiFlash version? (Required)

v6.5.5

@JinheLin JinheLin added type/bug The issue is confirmed as a bug. severity/moderate 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. labels Feb 28, 2024
@JinheLin JinheLin changed the title Invalid default value under not strict sql mode may crash TiFlash Invalid default value under NOT strict sql mode may crash TiFlash Feb 28, 2024
@JaySon-Huang JaySon-Huang changed the title Invalid default value under NOT strict sql mode may crash TiFlash Invalid default value of Decimal column under NOT strict sql mode may crash TiFlash Feb 29, 2024
@JaySon-Huang JaySon-Huang changed the title Invalid default value of Decimal column under NOT strict sql mode may crash TiFlash Invalid default value of Decimal column under NOT strict sql mode may make TiFlash panic Feb 29, 2024
@ti-chi-bot ti-chi-bot added affects-5.3 affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. labels Mar 1, 2024
This was referenced May 5, 2024
@seiya-annie
Copy link

/found customer

@ti-chi-bot ti-chi-bot bot added the report/customer Customers have encountered this bug. label Jun 4, 2024
@Lloyd-Pottiger Lloyd-Pottiger added the affects-8.1 This bug affects the 8.1.x(LTS) versions. label Jul 29, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this issue Jul 29, 2024
@Lloyd-Pottiger Lloyd-Pottiger removed the affects-8.1 This bug affects the 8.1.x(LTS) versions. label Jul 29, 2024
@JaySon-Huang
Copy link
Contributor

JaySon-Huang commented Jul 29, 2024

Note: does not affect 8.1. Have been fixed before v8.1.0

JaySon-Huang pushed a commit to JaySon-Huang/tiflash that referenced this issue Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.3 affects-5.4 This bug affects the 5.4.x(LTS) versions. 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.0 component/storage report/customer Customers have encountered this bug. severity/moderate type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants