in the database oc_file_locks , sometimes there thousands of record , is there a way to see why this happens ?
No idea. But perhaps you can optimize Nextcloud with using cron.php instead of AJAX if not yet configured.
why cron job will help?
which type of cron job i have to run, or only run cron.php is ok ?
Only “cron.php”. Perhaps it solves your problem. Test both once and look for differences.
sudo -u www-data php cron.php
sudo -u www-data php occ system:cron