Duplicate records in visits log

We have matomo running on one of the site, we are tracking logins along with user id, randomly a blank duplicate entry is created in visits log. we have used setuserid to pass login userid along with the request. we have most of the records with user id and somtimes randomly duplicate entries are created with no user id. how can we fix it?.