Add lock logic for MySQL and SQLite storage drivers