View the process that holds the lock of a specific table and the corresponding SQL statement

Execute the following statement:

select * from gp_toolkit.gp_locks_on_relation where lorrelname='<table>';

If you need to terminate the current query to release the lock, you can execute the select pg_terminate_backend(lorpid) statement. Example:

Lock wait prevention