MVCC does not mean "no locks" ... particularly not when UPDATEs are
involved. You'll need to be more specific about what your function is
doing, but my first thought would be to look for the possibility of
conflicting updates of the same row.
regards, tom lane