CESNET / netopeer2

NETCONF toolset
BSD 3-Clause "New" or "Revised" License
313 stars 194 forks source link

Edit-config success on server side , client side returned NC_MSG_WOULD_BLOCK #1720

Open sairohan0 opened 1 month ago

sairohan0 commented 1 month ago

Hello, I did a edit config using edit-config function in commands.c , the return value is -1, that is caused by NC_MSG_WOULD_BLCK from nc_send_rpc(). The send rpc timeout is only 1 second, so it could happen I guess., because I got failure in 1s. If it is failed in nc_recv_rpc() , it must take more than 5s. I checked more into it, nc_send_rpc calls nc_msg_send_io(), which in turn calls nc_write_msg_io() which calls nc_session_io_lock , that gives NC_MSG_WOULDBLOCK return value.

However, On the server side sysrepo, the configuration got deleted. I don't understand how could it happen. if nc_write_msg_io returns NC_MSG_WOULDBLOCK, how the rpc is sent to the server and server processed it and did the operations.

I got this issue many times, edit-config failing but the operation became successs on server side. How is it getting success, if the rpc not went to server?

Thank you.

michalvasko commented 1 month ago

if nc_write_msg_io returns NC_MSG_WOULDBLOCK, how the rpc is sent to the server and server processed it and did the operations.

I have no idea, looking at the code there is no way this can happen. But you calling CLI functions yourself points to some very strange use-case that I would blame for this issue. You should never encounter the issue if you just use the CLI.

sairohan0 commented 1 month ago

Could you say there could be cases when edit-config returns -ve value on client and config edit success on server side? There is a case of RPC_REPLY_TIMEOUT, Could there be any other?

michalvasko commented 1 month ago

There should be no such cases because nc_send_rpc() returns NC_MSG_WOULDBLOCK only if IO lock fails to be locked when it does not continue and does not send the RPC. If you observed anything else, please provide a way to reproduce it, I think it is impossible.