Backport a part of Monty's fix for Bug#39396, rev. 2736.2.11  "ha_maria.cc:2415: assertion in ha_maria::store_lock()".
Backport a part of Monty's fix for Bug#39396, rev. 2736.2.11 
"ha_maria.cc:2415: assertion in ha_maria::store_lock()".

sql/lock.cc:
  Fixed wrong cleanup of mysql_lock_tables()
  - We must call read_lock_data() BEFORE we set 
  lock_count to 0. Added DBUG statements.

flynn1973/mariadb-aix,davidl-zend/zenddbi,flynn1973/mariadb-aix,ollie314/server,davidl-zend/zenddbi,natsys/mariadb_10.2,natsys/mariadb_10.2,natsys/mariadb_10.2,ollie314/server,flynn1973/mariadb-aix,flynn1973/mariadb-aix,davidl-zend/zenddbi,ollie314/server,davidl-zend/zenddbi,natsys/mariadb_10.2,ollie314/server,davidl-zend/zenddbi,ollie314/server,davidl-zend/zenddbi,flynn1973/mariadb-aix,ollie314/server,flynn1973/mariadb-aix,flynn1973/mariadb-aix,flynn1973/mariadb-aix,flynn1973/mariadb-aix,flynn1973/mariadb-aix,ollie314/server,flynn1973/mariadb-aix,natsys/mariadb_10.2,davidl-zend/zenddbi,davidl-zend/zenddbi,ollie314/server,natsys/mariadb_10.2,davidl-zend/zenddbi,natsys/mariadb_10.2,davidl-zend/zenddbi,natsys/mariadb_10.2,davidl-zend/zenddbi,natsys/mariadb_10.2,ollie314/server,natsys/mariadb_10.2,ollie314/server,natsys/mariadb_10.2,slanterns/server,ollie314/server