Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Implemented the background thread for periodic syncing
Browse files Browse the repository at this point in the history
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: MariaDB/webscalesql-5.6#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
  • Loading branch information
maykov authored and Herman Lee committed Aug 27, 2015
1 parent e692b9e commit ef55f59
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 69 deletions.
33 changes: 31 additions & 2 deletions mysql-test/suite/rocksdb/write_sync.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
31 changes: 29 additions & 2 deletions mysql-test/suite/rocksdb/write_sync.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Loading

0 comments on commit ef55f59

Please sign in to comment.