Default value may cause more data inconsistency #4048
Labels
affects-6.0
affects-6.1
affects-6.2
area/ticdc
Issues or PRs related to TiCDC.
severity/moderate
type/bug
The issue is confirmed as a bug.
What did you do?
Default value may cause more data inconsistency. We create this issue to track related issue and progress.
First default value error is from #3793. In this case, I find TiDB "insert + amend + add column datetime default 'xxxx'" will trigger mounter getDefaultOrZeroValue logic, which means the new column is miss in the underlaying TiKV.
"getDefaultOrZeroValue" logic will return raw TiDB time type, which is not supported by go sql. So we format all default value or zero value.
After Pr for #3793, we find another panic issue raised by default value #3918. In this case, I find TiDB will return default value with string or int like type which is inconsistent with the original column type, and cdc get panic therefore.
Issue #3929 is found when testing issue 3918. It seems that when column data is miss in the underlaying TiKV, TiDB would use default value to fill the placeholder before checking not null flag.
After using default value to fill the placeholder before checking not null flag, I find the integration test multi_source always detect data inconsistency.
So, after discussing with wenjun, I find we use the wrong default value to fill the missing column data. We should use OriginalDefaultValue instead.
1.
OriginalDefaultValue
is set by "add column default xxx".2. Only
DefaultValue
will be set When we define columndefault xxx
in thecreate table
or callAlter/Change column
.When the
DefaultValue
is not null, TiDB will always insert the column data with default value to the underlying storge even we don't specify the column explicitly.TiDB will miss column data in the following 3 scenes:
At all these 3 scenes, OriginalDefaultValue is always consistent with the missing column data.
Please note that following scene will not cause missing column data:
So we can expect "getDefaultOrZeroValue" being called at following 4 scenes:
Currently, default value error (using wrong value to fill missing column data) will affect following scenes:
ToDoList:
Versions of the cluster
Upstream TiDB cluster version (execute
SELECT tidb_version();
in a MySQL client):v5.3.0
TiCDC version (execute
cdc version
):v5.4.0 and before
The text was updated successfully, but these errors were encountered: