Fix thread-safe issue replacing INSERT-UPDATE by MERGE command