ClickHouse/tests/queries/0_stateless/02883_zookeeper_finalize_stress.reference
Azat Khuzhin 5d3e3113b2 Fix possible CANNOT_READ_ALL_DATA exception during ZooKeeper client finalization
Right now it is possible to get this error CANNOT_READ_ALL_DATA if
timings will goes wrong.

The problem is that finalize() firstly calls shutdown() on the socket,
this will trigger poll(POLLIN) (EOF) and the receiveThread() will
trigger a receiveEvent which will fail because read will return 0
(while reading length).

Note, that rearrange the code in the finalize (i.e. call shutdown()
after) since the client sends CLOSE_XID before, and the server may close
the connection already, and this will also trigger poll(POLLIN) (EOF),
and read will return 0 also.

So checking for the requests_queue.isFinished() is not enough,
finalization_started should be checked instead.

Easy reproducer:

    $ yes /keeper/api_version | head -n10000 | xargs -P30 -i clickhouse-keeper-client -q 'get {}' > /dev/null

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-09-14 16:36:16 +02:00

0 lines
Plaintext