maedhroz commented on code in PR #4936:
URL: https://github.com/apache/cassandra/pull/4936#discussion_r3590923562
##########
src/java/org/apache/cassandra/transport/Dispatcher.java:
##########
@@ -480,11 +474,19 @@ static Message.Response processRequest(Channel channel,
Message.Request request,
void processRequest(Channel channel, Message.Request request,
FlushItemConverter forFlusher, Overload backpressure, RequestTime requestTime)
{
Message.Response response = processRequest(channel, request,
backpressure, requestTime);
- FlushItem<?> toFlush = forFlusher.toFlushItem(channel, request,
response);
+ FlushItem<?> toFlush = forFlusher.toFlushItem(channel, request,
decorateResponse(response, request));
Message.logger.trace("Responding: {}, v={}", response,
request.connection().getVersion());
flush(toFlush);
}
+ private static Message.Response decorateResponse(Message.Response
response, Message.Request request)
+ {
+ assert response != null;
+ response.setStreamId(request.getStreamId());
+ response.setWarnings(ClientWarn.instance.getWarnings());
Review Comment:
I think this is too late to set warnings. The `finally` that resets warnings
happens before this. The following test passes again if we move the warning
setting back to the pre-patch location:
```
@Test
public void warningsAreDeliveredToClient() throws Throwable
{
try (Cluster cluster = init(Cluster.build().withNodes(1)
.withConfig(config ->
config.with(GOSSIP, NETWORK, NATIVE_PROTOCOL)
.set("tombstone_warn_threshold", 0)).start()))
{
cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int
PRIMARY KEY, v int)");
// insert a row so a tombstone is generated
cluster.coordinator(1).execute("INSERT INTO " + KEYSPACE + ".tbl
(pk, v) VALUES (1, 1)", ConsistencyLevel.ONE);
cluster.coordinator(1).execute("DELETE v FROM " + KEYSPACE +
".tbl WHERE pk = 1", ConsistencyLevel.ONE);
String address =
cluster.get(1).config().broadcastAddress().getAddress().getHostAddress();
int port = cluster.get(1).callOnInstance(() ->
getNativeTransportPort());
try (SimpleClient client = SimpleClient.builder(address, port)
.protocolVersion(ProtocolVersion.V5)
.build().connect(false))
{
QueryMessage query = new QueryMessage("SELECT * FROM " +
KEYSPACE + ".tbl WHERE pk = 1", QueryOptions.DEFAULT);
Message.Response response = client.execute(query);
Assert.assertNotNull("Expected warnings on response, got
none", response.getWarnings());
Assert.assertFalse("Expected non-empty warnings list",
response.getWarnings().isEmpty());
}
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]