NdbAddingErrorInjection
A list of injectable errors is kept in storage/ndb/src/kernel/blocks/ERROR_codes.txt
Look at the latest numbers in the latest trees so that you get a new one. Each block starts at a particular offset.
A patch adding an error code may look like:
--- 1.27/storage/ndb/src/kernel/blocks/ERROR_codes.txt 2006-10-18 18:19:21 +10:00 +++ 1.28/storage/ndb/src/kernel/blocks/ERROR_codes.txt 2006-10-18 18:19:21 +10:00 @@ -8,7 +8,7 @@ Next DBDIH 7178 Next DBTC 8038 Next CMVMI 9000 -Next BACKUP 10022 +Next BACKUP 10036 Next DBUTIL 11002 Next DBTUX 12008 Next SUMA 13001
You also (should) add a description in the appropriate section. In this patch hunk, this documents (somewhat poorly) errors 10031 through 10035.
@@ -411,6 +411,11 @@ 10028: Abort backup by error at reception of BACKUP_FRAGMENT_CONF at master (code 305) 10029: Abort backup by error at reception of FSAPPENDCONF in slave (FileOrScanError = 5) 10030: Simulate buffer full from trigger execution => abort backup +10031: Error 331 for dictCommitTableMutex_locked +10032: backup checkscan +10033: backup checkscan +10034: define backup reply error +10035: Fail to allocate buffers 11001: Send UTIL_SEQUENCE_REF (in master)
In your code, you can check the result of ERROR_INSERTED(number) and perform an action if that error is inserted. An example of an error injection of failing to seize some pages is:
if(ERROR_INSERTED(10035) || files[i].p->pages.seize(noOfPages[i]) == false)
{
jam();
DEBUG_OUT("Failed to seize " << noOfPages[i] << " pages");
defineBackupRef(signal, ptr, DefineBackupRef::FailedToAllocateBuffers);
}
The aim of this is to "fail" to seize the pages needed and test the failure code (signaled by sending the REFused signal).
You can also insert a crash if a particular error has been inserted. e.g.
CRASH_INSERTION((10001));