Suppose we have a blog tool where each time a user performs a modification on an Article(Id,Body,Revisions), the revision counter is incremented by 1. If we wou
Yes, this is thread-safe. The database engine will lock the record during the update, which means any other threads will have to wait for it to finish its update.
During that time the field will indeed increment with one, without any interference from other threads. Once done, the resource is unlocked, and the next waiting thread will lock it in turn, and do the same.
As explained in the docs, the lock is an exclusive one:
Exclusive (X) Used for data-modification operations, such as INSERT, UPDATE, or DELETE. Ensures that multiple updates cannot be made to the same resource at the same time.
and:
Exclusive Locks
Exclusive (X) locks prevent access to a resource by concurrent transactions. No other transactions can read or modify data locked with an exclusive (X) lock.