From b35f04c110da26b8d6a1329805a5ebb65ab18b1c Mon Sep 17 00:00:00 2001 From: Alexey Maykov Date: Fri, 19 Dec 2014 23:45:32 -0800 Subject: [PATCH] Implemented the background thread for periodic syncing Summary: Starting a new thread which is used to periodically sync writes. Changed sysvars to directly mimic WriteOptions. Introduced a separate global sysvar to control the background sync thread. This diff is for this issue: https://github.com/MariaDB/webscalesql-5.6/issues/15 Test Plan: ran the test. A number of syncs doesn't go up in the background mode. It goes up after a second sleep Checked in gdb that correct write_options are set for truncate table and drop table Reviewers: jonahcohen, sergey.petrunya.9, MarkCallaghan Reviewed By: MarkCallaghan Differential Revision: https://reviews.facebook.net/D31221 --- mysql-test/suite/rocksdb/write_sync.result | 33 ++++++++++++++++++++-- mysql-test/suite/rocksdb/write_sync.test | 31 ++++++++++++++++++-- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/rocksdb/write_sync.result b/mysql-test/suite/rocksdb/write_sync.result index a9ae0a8c1149..8de770756bf8 100644 --- a/mysql-test/suite/rocksdb/write_sync.result +++ b/mysql-test/suite/rocksdb/write_sync.result @@ -3,7 +3,7 @@ SET GLOBAL rocksdb_write_timeout_hint_us=555; SET GLOBAL rocksdb_write_ignore_missing_column_families=true; create table aaa (id int primary key, i int) engine rocksdb; select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced'; -SET GLOBAL rocksdb_write_sync=off; +SET LOCAL rocksdb_write_sync=off; insert aaa(id, i) values(1,1); select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; select @b-@a; @@ -22,7 +22,7 @@ select @b-@a; @b-@a 0 set @a=@b; -SET GLOBAL rocksdb_write_sync=on_commit; +SET LOCAL rocksdb_write_sync=1; insert aaa(id, i) values(4,1); select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; select @b-@a; @@ -41,8 +41,37 @@ select @b-@a; @b-@a 1 set @a=@b; +SET GLOBAL rocksdb_background_sync=on; +SET LOCAL rocksdb_write_sync=off; +insert aaa(id, i) values(7,1); +select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; +select @b-@a; +@b-@a +0 +set @a=@b; +insert aaa(id, i) values(8,1); +select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; +select @b-@a; +@b-@a +0 +set @a=@b; +insert aaa(id, i) values(9,1); +select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; +select @b-@a; +@b-@a +0 +set @a=@b; +select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; +select @b-@a; +@b-@a +1 +set @a=@b; +SET LOCAL rocksdb_write_timeout_hint_us=333; +truncate table aaa; +SET LOCAL rocksdb_write_timeout_hint_us=444; drop table aaa; SET GLOBAL rocksdb_write_sync=off; SET GLOBAL rocksdb_write_disable_wal=false; SET GLOBAL rocksdb_write_timeout_hint_us=0; SET GLOBAL rocksdb_write_ignore_missing_column_families=false; +SET GLOBAL rocksdb_background_sync=off; diff --git a/mysql-test/suite/rocksdb/write_sync.test b/mysql-test/suite/rocksdb/write_sync.test index 8a53573b2bb6..ef898dfe84de 100644 --- a/mysql-test/suite/rocksdb/write_sync.test +++ b/mysql-test/suite/rocksdb/write_sync.test @@ -5,7 +5,7 @@ SET GLOBAL rocksdb_write_ignore_missing_column_families=true; create table aaa (id int primary key, i int) engine rocksdb; select variable_value into @a from information_schema.global_status where variable_name='rocksdb_wal_synced'; -SET GLOBAL rocksdb_write_sync=off; +SET LOCAL rocksdb_write_sync=off; insert aaa(id, i) values(1,1); select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; select @b-@a; @@ -19,7 +19,7 @@ select variable_value into @b from information_schema.global_status where variab select @b-@a; set @a=@b; -SET GLOBAL rocksdb_write_sync=on_commit; +SET LOCAL rocksdb_write_sync=1; insert aaa(id, i) values(4,1); select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; select @b-@a; @@ -33,10 +33,37 @@ select variable_value into @b from information_schema.global_status where variab select @b-@a; set @a=@b; +SET GLOBAL rocksdb_background_sync=on; +SET LOCAL rocksdb_write_sync=off; +insert aaa(id, i) values(7,1); +select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; +select @b-@a; +set @a=@b; +insert aaa(id, i) values(8,1); +select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; +select @b-@a; +set @a=@b; +insert aaa(id, i) values(9,1); +select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; +select @b-@a; +set @a=@b; + +let $status_var=rocksdb_wal_synced; +let $status_var_value=5; +source include/wait_for_status_var.inc; +select variable_value into @b from information_schema.global_status where variable_name='rocksdb_wal_synced'; +select @b-@a; +set @a=@b; + +SET LOCAL rocksdb_write_timeout_hint_us=333; +truncate table aaa; + # Cleanup +SET LOCAL rocksdb_write_timeout_hint_us=444; drop table aaa; SET GLOBAL rocksdb_write_sync=off; SET GLOBAL rocksdb_write_disable_wal=false; SET GLOBAL rocksdb_write_timeout_hint_us=0; SET GLOBAL rocksdb_write_ignore_missing_column_families=false; +SET GLOBAL rocksdb_background_sync=off;