paul-rogers commented on a change in pull request #11828: URL: https://github.com/apache/druid/pull/11828#discussion_r747827403
########## File path: processing/src/main/java/org/apache/druid/query/context/ResponseContextDeserializer.java ########## @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.query.context; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + +import java.io.IOException; + +@SuppressWarnings("serial") +public class ResponseContextDeserializer extends StdDeserializer<ResponseContext> +{ + public ResponseContextDeserializer() + { + super(ResponseContext.class); + } + + @Override + public ResponseContext deserialize( + final JsonParser jp, + final DeserializationContext ctxt + ) throws IOException + { + if (jp.currentToken() != JsonToken.START_OBJECT) { + throw ctxt.wrongTokenException(jp, ResponseContext.class, JsonToken.START_OBJECT, null); + } + + // TODO(gianm): Check if we need concurrent response context here Review comment: Well, I guess I hoped that you or Gian knew! This seems like a tricky case: the deserializer can't know how the deserialized context will be used. It seems reasonable that each "receiver" (Druid client) will send its context downstream to where it is merged into a potentially concurrent context. It is not obvious from this code if somewhere in that process the deserialized context is shared across threads. Actually, this whole area is ripe for rework: even a concurrent context has race conditions if we add to a structured property, such as the list of missing segments. Things like row count (used for offset) become ill-defined if the row count can be changed by other threads concurrently with the one trying to decide where to start reading. Clearly, what's here works for what it does, but is a bit fragile if we ask the response context to do more. -- 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]
