@ -48,7 +48,8 @@ class ErrorHandlerListener : public EventListener {
file_count_ ( 0 ) ,
file_count_ ( 0 ) ,
fault_env_ ( nullptr ) { }
fault_env_ ( nullptr ) { }
void OnTableFileCreationStarted ( const TableFileCreationBriefInfo & /*ti*/ ) {
void OnTableFileCreationStarted (
const TableFileCreationBriefInfo & /*ti*/ ) override {
InstrumentedMutexLock l ( & mutex_ ) ;
InstrumentedMutexLock l ( & mutex_ ) ;
file_creation_started_ = true ;
file_creation_started_ = true ;
if ( file_count_ > 0 ) {
if ( file_count_ > 0 ) {
@ -61,13 +62,14 @@ class ErrorHandlerListener : public EventListener {
}
}
void OnErrorRecoveryBegin ( BackgroundErrorReason /*reason*/ ,
void OnErrorRecoveryBegin ( BackgroundErrorReason /*reason*/ ,
Status /*bg_error*/ , bool * auto_recovery ) {
Status /*bg_error*/ ,
bool * auto_recovery ) override {
if ( * auto_recovery & & no_auto_recovery_ ) {
if ( * auto_recovery & & no_auto_recovery_ ) {
* auto_recovery = false ;
* auto_recovery = false ;
}
}
}
}
void OnErrorRecoveryCompleted ( Status /*old_bg_error*/ ) {
void OnErrorRecoveryCompleted ( Status /*old_bg_error*/ ) override {
InstrumentedMutexLock l ( & mutex_ ) ;
InstrumentedMutexLock l ( & mutex_ ) ;
recovery_complete_ = true ;
recovery_complete_ = true ;
cv_ . SignalAll ( ) ;
cv_ . SignalAll ( ) ;
@ -237,7 +239,6 @@ TEST_F(DBErrorHandlingTest, CorruptionError) {
Destroy ( options ) ;
Destroy ( options ) ;
}
}
# ifndef TRAVIS
TEST_F ( DBErrorHandlingTest , AutoRecoverFlushError ) {
TEST_F ( DBErrorHandlingTest , AutoRecoverFlushError ) {
std : : unique_ptr < FaultInjectionTestEnv > fault_env (
std : : unique_ptr < FaultInjectionTestEnv > fault_env (
new FaultInjectionTestEnv ( Env : : Default ( ) ) ) ;
new FaultInjectionTestEnv ( Env : : Default ( ) ) ) ;
@ -307,17 +308,16 @@ TEST_F(DBErrorHandlingTest, WALWriteError) {
options . env = fault_env . get ( ) ;
options . env = fault_env . get ( ) ;
options . listeners . emplace_back ( listener ) ;
options . listeners . emplace_back ( listener ) ;
Status s ;
Status s ;
Random rnd ( 301 ) ;
listener - > EnableAutoRecovery ( ) ;
listener - > EnableAutoRecovery ( ) ;
DestroyAndReopen ( options ) ;
DestroyAndReopen ( options ) ;
{
{
WriteBatch batch ;
WriteBatch batch ;
char val [ 1024 ] ;
for ( auto i = 0 ; i < 100 ; + + i ) {
for ( auto i = 0 ; i < 100 ; + + i ) {
sprintf ( val , " %d " , i ) ;
batch . Put ( Key ( i ) , RandomString ( & rnd , 1024 ) ) ;
batch . Put ( Key ( i ) , Slice ( val , sizeof ( val ) ) ) ;
}
}
WriteOptions wopts ;
WriteOptions wopts ;
@ -327,12 +327,10 @@ TEST_F(DBErrorHandlingTest, WALWriteError) {
{
{
WriteBatch batch ;
WriteBatch batch ;
char val [ 1024 ] ;
int write_error = 0 ;
int write_error = 0 ;
for ( auto i = 100 ; i < 199 ; + + i ) {
for ( auto i = 100 ; i < 199 ; + + i ) {
sprintf ( val , " %d " , i ) ;
batch . Put ( Key ( i ) , RandomString ( & rnd , 1024 ) ) ;
batch . Put ( Key ( i ) , Slice ( val , sizeof ( val ) ) ) ;
}
}
SyncPoint : : GetInstance ( ) - > SetCallBack ( " WritableFileWriter::Append:BeforePrepareWrite " , [ & ] ( void * ) {
SyncPoint : : GetInstance ( ) - > SetCallBack ( " WritableFileWriter::Append:BeforePrepareWrite " , [ & ] ( void * ) {
@ -378,18 +376,17 @@ TEST_F(DBErrorHandlingTest, MultiCFWALWriteError) {
options . env = fault_env . get ( ) ;
options . env = fault_env . get ( ) ;
options . listeners . emplace_back ( listener ) ;
options . listeners . emplace_back ( listener ) ;
Status s ;
Status s ;
Random rnd ( 301 ) ;
listener - > EnableAutoRecovery ( ) ;
listener - > EnableAutoRecovery ( ) ;
CreateAndReopenWithCF ( { " one " , " two " , " three " } , options ) ;
CreateAndReopenWithCF ( { " one " , " two " , " three " } , options ) ;
{
{
WriteBatch batch ;
WriteBatch batch ;
char val [ 1024 ] ;
for ( auto i = 1 ; i < 4 ; + + i ) {
for ( auto i = 1 ; i < 4 ; + + i ) {
for ( auto j = 0 ; j < 100 ; + + j ) {
for ( auto j = 0 ; j < 100 ; + + j ) {
sprintf ( val , " %d " , j ) ;
batch . Put ( handles_ [ i ] , Key ( j ) , RandomString ( & rnd , 1024 ) ) ;
batch . Put ( handles_ [ i ] , Key ( j ) , Slice ( val , sizeof ( val ) ) ) ;
}
}
}
}
@ -400,13 +397,11 @@ TEST_F(DBErrorHandlingTest, MultiCFWALWriteError) {
{
{
WriteBatch batch ;
WriteBatch batch ;
char val [ 1024 ] ;
int write_error = 0 ;
int write_error = 0 ;
// Write to one CF
// Write to one CF
for ( auto i = 100 ; i < 199 ; + + i ) {
for ( auto i = 100 ; i < 199 ; + + i ) {
sprintf ( val , " %d " , i ) ;
batch . Put ( handles_ [ 2 ] , Key ( i ) , RandomString ( & rnd , 1024 ) ) ;
batch . Put ( handles_ [ 2 ] , Key ( i ) , Slice ( val , sizeof ( val ) ) ) ;
}
}
SyncPoint : : GetInstance ( ) - > SetCallBack (
SyncPoint : : GetInstance ( ) - > SetCallBack (
@ -462,6 +457,7 @@ TEST_F(DBErrorHandlingTest, MultiDBCompactionError) {
std : : vector < DB * > db ;
std : : vector < DB * > db ;
std : : shared_ptr < SstFileManager > sfm ( NewSstFileManager ( def_env ) ) ;
std : : shared_ptr < SstFileManager > sfm ( NewSstFileManager ( def_env ) ) ;
int kNumDbInstances = 3 ;
int kNumDbInstances = 3 ;
Random rnd ( 301 ) ;
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
listener . emplace_back ( new ErrorHandlerListener ( ) ) ;
listener . emplace_back ( new ErrorHandlerListener ( ) ) ;
@ -489,11 +485,9 @@ TEST_F(DBErrorHandlingTest, MultiDBCompactionError) {
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
WriteBatch batch ;
WriteBatch batch ;
char val [ 1024 ] ;
for ( auto j = 0 ; j < = 100 ; + + j ) {
for ( auto j = 0 ; j < = 100 ; + + j ) {
sprintf ( val , " %d " , j ) ;
batch . Put ( Key ( j ) , RandomString ( & rnd , 1024 ) ) ;
batch . Put ( Key ( j ) , Slice ( val , sizeof ( val ) ) ) ;
}
}
WriteOptions wopts ;
WriteOptions wopts ;
@ -505,12 +499,10 @@ TEST_F(DBErrorHandlingTest, MultiDBCompactionError) {
def_env - > SetFilesystemActive ( false , Status : : NoSpace ( " Out of space " ) ) ;
def_env - > SetFilesystemActive ( false , Status : : NoSpace ( " Out of space " ) ) ;
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
WriteBatch batch ;
WriteBatch batch ;
char val [ 1024 ] ;
// Write to one CF
// Write to one CF
for ( auto j = 100 ; j < 199 ; + + j ) {
for ( auto j = 100 ; j < 199 ; + + j ) {
sprintf ( val , " %d " , j ) ;
batch . Put ( Key ( j ) , RandomString ( & rnd , 1024 ) ) ;
batch . Put ( Key ( j ) , Slice ( val , sizeof ( val ) ) ) ;
}
}
WriteOptions wopts ;
WriteOptions wopts ;
@ -561,6 +553,7 @@ TEST_F(DBErrorHandlingTest, MultiDBVariousErrors) {
std : : vector < DB * > db ;
std : : vector < DB * > db ;
std : : shared_ptr < SstFileManager > sfm ( NewSstFileManager ( def_env ) ) ;
std : : shared_ptr < SstFileManager > sfm ( NewSstFileManager ( def_env ) ) ;
int kNumDbInstances = 3 ;
int kNumDbInstances = 3 ;
Random rnd ( 301 ) ;
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
listener . emplace_back ( new ErrorHandlerListener ( ) ) ;
listener . emplace_back ( new ErrorHandlerListener ( ) ) ;
@ -600,11 +593,9 @@ TEST_F(DBErrorHandlingTest, MultiDBVariousErrors) {
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
WriteBatch batch ;
WriteBatch batch ;
char val [ 1024 ] ;
for ( auto j = 0 ; j < = 100 ; + + j ) {
for ( auto j = 0 ; j < = 100 ; + + j ) {
sprintf ( val , " %d " , j ) ;
batch . Put ( Key ( j ) , RandomString ( & rnd , 1024 ) ) ;
batch . Put ( Key ( j ) , Slice ( val , sizeof ( val ) ) ) ;
}
}
WriteOptions wopts ;
WriteOptions wopts ;
@ -616,12 +607,10 @@ TEST_F(DBErrorHandlingTest, MultiDBVariousErrors) {
def_env - > SetFilesystemActive ( false , Status : : NoSpace ( " Out of space " ) ) ;
def_env - > SetFilesystemActive ( false , Status : : NoSpace ( " Out of space " ) ) ;
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
for ( auto i = 0 ; i < kNumDbInstances ; + + i ) {
WriteBatch batch ;
WriteBatch batch ;
char val [ 1024 ] ;
// Write to one CF
// Write to one CF
for ( auto j = 100 ; j < 199 ; + + j ) {
for ( auto j = 100 ; j < 199 ; + + j ) {
sprintf ( val , " %d " , j ) ;
batch . Put ( Key ( j ) , RandomString ( & rnd , 1024 ) ) ;
batch . Put ( Key ( j ) , Slice ( val , sizeof ( val ) ) ) ;
}
}
WriteOptions wopts ;
WriteOptions wopts ;
@ -682,7 +671,6 @@ TEST_F(DBErrorHandlingTest, MultiDBVariousErrors) {
options . clear ( ) ;
options . clear ( ) ;
delete def_env ;
delete def_env ;
}
}
# endif
} // namespace rocksdb
} // namespace rocksdb