Wrap permalink saving in a with_lock block to lock the table during updating
Wrap permalink saving in a with_lock block to lock the table during updating

In addition, only select the permalink field from the table when querying all similarly-prefixed permalinks

This should prevent duplicate permalinks being generated by different processes hitting the database at the same time.

Fixes #2714

Antdesk/karpal-spree,Antdesk/karpal-spree,Antdesk/karpal-spree