Description
I just observed during development that the NFSv4 implementation on macOS may (only sometimes!) not like it very much when the NFS server gets restarted while an I/O write operation is happening at the same time:
Upon server restart, the client may retry the write using a stateid of "-1" and an "other" clientid of "ffffffffffffffffffffffff", which will obviously never succeed.
This effectively slows down everything, the client and the server, until nothing gets sent anymore (throughput down from ca. 1600 MB/s to 5kb/s ...)
Adding some code that checks for this bad stateid in NFSv4StateHandler, throwing a BadSessionException instead of a BadStateidException seems to fix the issue, causing the macOS client to reconnect and properly setup their state ids, etc.