If you need to change the file owner (*1) after changing the file mode (*2) to the same file, perform both operations on the same node.
*1 File owner change using a command such as chown(1), chown(2), or fchown(2)
*2 File mode change using a command such as chmod(1), chmod(2), or fchmod(2)
If you perform file owner change after file mode change for the same file from the other node, the file might go back to the previous mode. You can prevent this problem by acquiring (*3) updated file information before changing file owner.
*3 File information acquisition using a command such as stat(1), stat(2), or fstat(2)