Timestamp時間戳精確到微妙級別,出現bug

2021-09-03 06:37:25 字數 806 閱讀 7552

timestamp時間戳精確到微妙級別,出現bug

自mariadb5.3版本起,timestamp時間戳精確到微妙級別,但這裡存在乙個致命bug,它會導致binlog記錄的內容損壞,致使閃回恢復功能失效、canal工具抓取binlog失敗。

影響版本mariadb 5.5/10.0

復現:我使用的版本為10.0.29-mariadb-enterprise

binlog格式為row(mixed不存在此bug)

建立表結構,注意:timestamp(6),精確到微妙

create table hcy(create_time timestamp(6) not null default current_timestamp(6));

插入資料

insert into hcy(create_time) values(now());

此時我們檢視binlog檔案,如下圖所示:

1、時間變成了負數。

2、corrupted replication event was detected. 檢測到複製被損壞。

3、10.0低版本可能會造成主從同步失敗。

該bug在mariadb 10.1版本裡修復

官方確認bug位址

時間戳TimeStamp處理

我獲得這個時間戳是得想除以1000再處理的,看看你們的需要先除多少再處理 時間戳處理 nsinteger time timestamp 1000 nsnumber timer nsnumber numberwithinteger time nstimeinterval interval timer ...

TimesTen 時間戳 timestamp 用法

很多時候我們需要對資料庫進行增量更新,比如從timesten資料庫匯入資料到mysql資料庫中。為了保證匯入是增量的,我們必須跳過那些沒有 被修改過的資料,現在比較流行的方法是使用時間戳,也就是定義乙個型別為timestamp的新列。當我們對這個表增加或刪除行時,必須更新這個列的資料,以反映行被更新...

MySQL 時間戳(Timestamp)函式

1.mysql 獲得當前時間戳函式 current timestamp,current timestamp mysql select current timestamp,current timestamp current timestamp current timestamp 2008 08 09 ...