WL#9383: INNODB: ADD AN OPTION TO TURN OFF/ON DEADLOCK CHECKER

Affects: Server-8.0   —   Status: Complete   —   Priority: Medium

Deadlock detection code can be expensive when a lots of threads wait for the same 
lock i.e.: a hotspot scenario. At times, it is much more efficient to disable 
deadlock detection code and rely on innodb_lock_wait_timeout to rollback in case 
of deadlock.
Functional and Non-Functional Requirements
F-1: Add a global system variable innodb_deadlock_detect with default value 'ON'.
F-2: User must be able to trun off/on deadlock checker by innodb_deadlock_detect 
in runtime.
F-3: Deadlock check must be skipped if innodb_deadlock_detect is 'OFF'.

Non-Functional requirements:
NF-1: Disable deadlock checker shall improve transaction throughput and reduce 
response time in case that deadlock checker takes lots of time(e.g. lots of 
threads wait for the same lock).
NF-2: Implicit requirements: Follow the SQL standard, work on all  platforms, do 
not break replication, backup, partitioning, FK, or any  other existing features.
1. innodb_deadlock_detect is a global variable.
2. innodb_deadlock_detect can be changed dynamically.
3. Skip deadlock check when acquiring table/row lock if innodb_deadlock_detect is 
'OFF'.
1.Add innodb_deadlock_detect as a global variable.
storage/innobase/handler/ha_innodb.cc:
static MYSQL_SYSVAR_BOOL(deadlock_detect, innobase_deadlock_detect,
  PLUGIN_VAR_NOCMDARG,
  "Disable InnoDB deadlock detector, so rely on innodb_lock_wait_timeout to 
rollback in case of deadlock.",
  NULL, NULL, TRUE);

2. Skip deadlock when innodb_deadlock_detect is 'OFF'.
storage/innobase/lock/lock0lock.cc:
DeadlockChecker::check_and_resolve(const lock_t* lock, const trx_t* trx)
...
if (!innobase_deadlock_detect) {
		return(NULL);
	}
...