The function lock_update_discard() starts with an incorrect check:
This fails to account for lock_sys->prdt_page_hash. If such locks exist on the page, they will not be discarded.
Also, the function is unnecessarily traversing both B-tree record locks and predicate locks for the same pages. Predicate locks exist only on spatial index pages, and B-tree record locks only exist on B-tree index pages.