External version control with update_by_query

I have a use-case where I want to have an external version control with update_by_query. The same document might get updated a million times so retrying on version conflict is not an option. Any pointers on how to implement this.