Flashback feature for MySQL


本文转载自:http://mysql.taobao.org/index.php/Patch_source_code#Add_flashback_feature_for_mysqlbinlog


Patch source code

目录

  [隐藏]
  • 1 Server Patches (Base Percona 5.5.18)
    • 1.1 Multi-master replication
    • 1.2 Kill idle transaction
    • 1.3 per-thread memory usage statistics
    • 1.4 buf fix : create table using convert may cause replication stop
    • 1.5 InnoDB pre-alloc tablespace
    • 1.6 Optimization when copy int data
    • 1.7 Correct update_time of InnoDB table
    • 1.8 Optimization of "order by rand()"
    • 1.9 Purge thread exception cause innodb init fail
    • 1.10 Fix bug caused by userstat
    • 1.11 A new value of slave_exec_mode to handle slave error
    • 1.12 A new column shows the active time of current transaction
    • 1.13 Doublebinlog for MySQL
    • 1.14 dynamic switch for performance schema
  • 2 mysql tools patches (Base Percona 5.5.18)
    • 2.1 Full query for mysqldump
    • 2.2 Report progress for mysqldump
    • 2.3 Forbid add-drop-database deleting `mysql`
    • 2.4 prefetch data for slave with relay-fetch
    • 2.5 Add flashback feature for mysqlbinlog
    • 2.6 Flashback feature for MySQL
  • 3 Bug fixes and feature enhancement in community
    • 3.1 mysql enhance semi-sync replication feature (MySQL-5.5)
    • 3.2 the original table missing while execute the ddl 'alter table add column '
    • 3.3 event is passed back and forth between dual master if event is from some other mysqld
    • 3.4 connection is refused while excuting "flush privileges"
    • 3.5 init_connect would kill current connection if read_only is on for some case
    • 3.6 enhanced binlog row verbose shown for the escape characters
    • 3.7 Fix MVCC broken with implicit lock
    • 3.8 Fix for bug of optimizer
  • 4 MySQL Transfer (Base MySQL/Oracle 5.1.48)

Server Patches (Base Percona 5.5.18)

 All the patches list here can be use "patch -p0 < fname" directly on Percona Server 5.5.18.

Multi-master replication

from plinux

There is some requirement that one slave replicates data from several masters. Multi-master replication patch modifies the slave server, makes it can register itself as slave of more than one masters. Data from these masters should guaranteed that there are no conflicts.

[source code]


Kill idle transaction

from plinux

MySQL Server Kill Idle Transaction patch, it can clear all idle transaction and release their locks. I provide three options, they can control how long to kill read-only transactions or write transactions, and all transactions.

[source code]


per-thread memory usage statistics

from plinux

This patch can display how many memory used of threads, it will let DBAs know the memory cost detail.

[source code]

buf fix : create table using convert may cause replication stop

from dingqi

As descripe here, when runs create table statement "create table tmpp as select b.a, cast(substr(a.feature,15) as signed integer) from t1 a, t2 b;" , the binlog will record the third column as bigint(7986). This query can not reply in slave, because the fieldwidth of a bigint can not bigger than 255.

This patch changes the statement that log into master's binlog. It limits the fieldwidth of a bigint and int, not more than 255.

[source code]

InnoDB pre-alloc tablespace

from dingqi

In some applications, the InnoDB tables grow rapidly. If the tablespace can be extended beforehand, the tps can be benefit.

New command "alter tablespace `dbname/tblname` set extent_size=1024;" can be used to extend the size of tblname.ibd file to 16M.

[source code]


Optimization when copy int data

from dingqi

Code of translating from little-endian to big-endian cost CPU. We can change it from using "for" statement to assamble code. This save 10% of cpu usage in my test case, which needs to retrive lots of int data from InnoDB engine to MySQL server.

[source code]


Correct update_time of InnoDB table

from dingqi

InnoDB tables always have an update_time of NULL when doing SHOW TABLE STATUS. It is true that there is not place to record the last update time of a table, but for tables that created under innodb_file_per_table mode, which is more common now, we can simply get it from the mtime of the ibd file.

[source code]


Optimization of "order by rand()"

from dingqi

As "explain select * from table_name order by rand()" , we can find "Using temporary" in the Extra info. This patch makes such a query do not use temporary table, so improve performance.

[source code]


Purge thread exception cause innodb init fail

from yinfeng

The server can't start When starting with innodb_force_recovery>2 and innodb_purge_thread =1

[source code]


Fix bug caused by userstat

from yinfeng

mysqld can't startup when a plugin had being installed and userstat=1

[source code]

A new value of slave_exec_mode to handle slave error

from yinfeng

a new value of slave_exec_mode to handle slave error: SMART, and the basic idea is:

1) HA_ERR_KEY_NOT_FOUND
UPDATE_ROWS_EVENT: write 'Before Image' of the record, and then update it
DELETE_ROWS_EVENT: write the record and then delete it 

2)HA_ERR_FOUND_DUPP_KEY
WRITE_ROWS_EVENT: just overwrite the record
UPDATE_ROWS_EVENT : Not handled

[source code]

A new column shows the active time of current transaction

from dingqi

Adding a new column in the result of "show processlist". Some clients will run "begin; select * from t limit n",and then idle, which will affect the server. Such as the InnoDB share systemspace will become large. Such clients maybe bug from programs or some unreasonable operations from manual, monitors can get information from the output,warning or kill idle threads.

[source code]


Doublebinlog for MySQL

from dingqi

In some projects that require very strict data safety, DBAs will except there is a solution to ensure the safety of binlog. That means after the worst case, OS crash or disk damage, there is a way to find out a whole copy of binlog.

Doublebinlog patch is done for this requirement. It offers a switch to enable the behavior: any write and fsync operation on binary logs are duplicated in another file. So if the original binlog file is destroyed by disk damage, the bak file can be used.

[source code] More Detail

dynamic switch for performance schema

from dingqi

The Performance Schema provides a way to inspect internal execution of the server at runtime. But not a dynamic switch. This patch provides a parameter to switch the dynamically.

 set global performance_schema_collecting = on/off;

[source code]

mysql tools patches (Base Percona 5.5.18)

Full query for mysqldump

from dingqi

Assume that we need to dump table A using this query "select A.* from A,B where A.f1=B.f1 and B.f2=xxx", there are no proper parameters for the requirement in an efficient way. This patch of mysqldump provide a param "full-query" to allow users write full query to dump data.

The usage can be found in the test case in patch file.

[source code]

Report progress for mysqldump

from dingqi

Add progress report when mysqldump running. New parameter --report-progress for it.

Note:

1) if "-r" is not specified, report-progress is disable forcely.

2) if "--tab" is specified, report-progress can not take effect.

[source code]

Forbid add-drop-database deleting `mysql`

from dingqi

In normal running mysqld, the "log_slow_queries" is ON.

If runs mysqldump with --all-databases --add-drop-database and then run "mysql -e 'source dumpfile'", there is an error shows

"ERROR 1580 .... You cannot 'DROP' a log table if logging is enabled".

So we should forbid the dumpped file deleting database `mysql`.

[source code]

prefetch data for slave with relay-fetch

from yinfeng

A tool used to prefetch realy log for slave based on row replication, speeding the slave's performance, therefore, reduced the gap between master and slave without any injection for MySQL.

[source code]

Add flashback feature for mysqlbinlog

from plinux

Add an option "-B/--flashback" for mysqlbinlog tool, it can reverse binlog event type and reverse execution sequence.

[source code]

[source code, mysql CLI version]

Flashback feature for MySQL

from plinux dingqi

This patch allows you flashback to a point of MySQL, after mis-operation such as "forgot where clause when update or delete" and "drop or truncate table ", a new parameter -B for mysqlbinlog can provide the flashback statements.

This patch includes the flashback feature in above. What difference is that this one includes flashback for DDL operatins. So it changes the server code.

[source code]

Bug fixes and feature enhancement in community

mysql enhance semi-sync replication feature (MySQL-5.5)

from orczhou

resource in launchpad

the original table missing while execute the ddl 'alter table add column '

from xiyu

The patch fixed the possible thread deadlock risk for DDL. Tweaked patch is merged into 5.1.62, 5.5.22, 5.6.5.

Detail info and related patch would refer to: related bug


event is passed back and forth between dual master if event is from some other mysqld

from xiyu

Fixed the event with another server_id passing between dual-master, for the fail-over cluster. This patch fixed Taobao's automate switching detected bug.

Detail info and related patch would refer to: related bug

connection is refused while excuting "flush privileges"

from xiyu

When "flush privileges", most of the connections would be rejected, and it's caused a serious bug in FEED cluster of Taobao. This patch fixed the bug above.

Detail info and related patch would refer to: related bug

init_connect would kill current connection if read_only is on for some case

from xiyu

For the sake of auditing, init_connect is set with inserting access log info to accesslog table Once we forgot the remove the init_connect content after switch of master-slave, all connection would be killed. It's patched for all inner versions.

Detail info and related patch would refer to related bug

enhanced binlog row verbose shown for the escape characters

from xiyu

The stock binlog verbose output for row format is not friendly if we want to used for some other usage, such as rollback from binlog. This patch fixed the existing issues used for rollbacking from binlog, and used for TMHA.

Detail info and related patch would refer to related bug

Fix MVCC broken with implicit lock

from plinux

Because Primary Key Index use the del-marked entry to store new inserted entry, Secondary Index can't judge implicit lock.

Detail info and related patch would refer to related bug [source code]

Fix for bug of optimizer

from zzx

Different cost calculation of ref and range result in worse query plan. The bug was first seen at Bug#12113

[source code]

MySQL Transfer (Base MySQL/Oracle 5.1.48)

from dingqi

Transfer-MySQL is a tool for improving replication performance between MySQL master and slaves. Transfer is forked from MySQL source code (5.1.48) and acts as an independent process.

The struct simply as [MASTER -> TRANSFER => SLAVE]. TRANSFER is the direct slave of MASTER, and update SLAVE as a common client.

More Detail

An certainly, the "Transfer" can simply act as a slave,when we patch it to the slave.



注:近期参加MySQL运维学习,老师推荐该文章作为学习和技术提高的扩展阅读,先记录到自己的博客中,随后慢慢消化、学习、提高。本文章与“日志系统”主题相关。



你可能感兴趣的:(mysql)