On Thursday, 24 February 2022 at 08:46:35 UTC, eugene wrote:
On Saturday, 19 February 2022 at 20:13:01 UTC, Chris Piker
wrote:
3. Update/insert to a postgresql database as data arrive.
I've remembered one not so obvious feature of TCP sockets
behavour.
If the connection is closed on the server side
(i.e. on the client side the socket is in CLOSE_WAIT state),
**write() will not fail**, and data will go to no nowhere.
https://stackoverflow.com/questions/26130010/avoiding-dataloss-in-go-when-writing-with-close-wait-socket
In my case (I was working with REDIS KVS at the moment)
exact scenario was as follows:
* prog gets EPOLLOUT (write() won't block)
* prog writes()'s data to REDIS ("successfully")
* prog gets EPOLLERR|EPOLLHUP
After this I see that I need to reconnect, but I've already send
some data which had gone to nowhere.
People sometimes recommend using usual non-blocking sockets,
but it is not the case.