SOLR-18248 : Migration of Tasks V2 APIs to JAX-RS Constructs#4452
SOLR-18248 : Migration of Tasks V2 APIs to JAX-RS Constructs#4452jaykay12 wants to merge 55 commits into
Conversation
|
|
||
| import static org.apache.solr.client.api.util.Constants.INDEX_PATH_PREFIX; | ||
|
|
||
| @Path(INDEX_PATH_PREFIX + "/tasks/listjalaz") |
There was a problem hiding this comment.
;-) Look slike you have some debugging?
There was a problem hiding this comment.
yeah, started with firstly wiring this api to give any random response, & now using this to compare my V2 response with the original V2 response, 😄 thus, kept a different api endpoint for now to do response comparision.
will surely update this during self-review before raising for formal review 💯
epugh
left a comment
There was a problem hiding this comment.
Thanks for getting started on this, I went ahead and put some comments in that may be too early to be added ;-)
| @GET | ||
| @StoreApiParameters | ||
| @Operation( | ||
| summary = "Lists all the currently running tasks or status of any taskUUID being passed as queryParam", |
There was a problem hiding this comment.
So, I think we would revamp this api... if you look at the desired api, ListActiveTasks would just list all tasks. If you wanted a specfific task, then it would be a idfferent end point with a /taskUUID.
There was a problem hiding this comment.
yes, have updated this Api class for now, handling the taskUUID as a path param now, it was queryParam in the V1 as well as homegrown v2.
|
|
||
| public class ListActiveTaskResponse extends SolrJerseyResponse { | ||
| @JsonProperty | ||
| public Map<String, String> taskList; |
There was a problem hiding this comment.
We are trying to move to more strongly typed responses so taht we don't have Map everywhere. Go ahead and specify out the return properties!
There was a problem hiding this comment.
Yes, have done so.
|
|
||
| } | ||
|
|
||
| private void handleStandAloneMode(ListActiveTaskResponse response, String taskUUID) { |
There was a problem hiding this comment.
One thing we are trying to do is move the V1 API logic into the V2 code base, and have the V1 call the V2 version, this way, as these apis evolve, we know that v1 and v2 stay in sync till we get rid of V1. I believe that ideally we would want ActiveTasksListComponent to delegate to the same code as this V2 api. Now, maybe it's so simple that both can just call core getCancellableQueryTracker().getActiveQueriesGenerated. In other V2 apis, you can see the code live in the V2 and then V1 calls it...
There was a problem hiding this comment.
understood this part, have made suitable changes.
| log.debug("solr cloud"); | ||
| } | ||
| handleSolrCloudMode(response, taskUUID); | ||
| } else { |
There was a problem hiding this comment.
not quite sure I see the differences in the two paths yet?
There was a problem hiding this comment.
yea, i am also checking this up.
I have tested this endpoint by running on cloud example which we have in examples, it worked fine. It should work fine for standalone as well, will remove the current conditional branching done once that's verified.
thank you so much @epugh for the prompt reviews & initial guidance, much appreciated. I will keep addressing your comments as we go, I kept this PR as draft for now as per our community guidelines, but yea thanks again for reviewing this at such initial state, so that i can course correct myself promptly. ✨ |
| (isTaskActive) | ||
| ? TaskStatusResponse.TaskStatus.ACTIVE | ||
| : TaskStatusResponse.TaskStatus.INACTIVE; | ||
| response.taskStatus = (isTaskActive) ? TaskStatus.ACTIVE : TaskStatus.INACTIVE; |
Here is an example of sort of the testing I am looking for. In the reference PR I found a couple of commands that exercised the code externally, just to get more confidence. If you do the equivalent with some curl commands, that would give me more confidence. Plus, I'll run them and learn some stuff! #4320 (comment) |
|
@jaykay12 oh, we need to update the Reference Guide for any changes we've made in the V2 outputs as well ;-). If you hate doing that, I can do that ;-). |
Turns out I started this pattern, but it's not actually a pattern we want to support! So backing it out of the two places that have it.
|
Facing issues with the approach related to Nested Interfaces, API is not getting registered into Jersey & when trying to call V2 API it is throwing 404 error. Post this comment, I am reverting back those changes. Not removing the code changes entirely, but commenting them for now. Commit - d161485 - points to the code that is causing issue & what works fine. |
Test EvidencesHow I verified that these changes work via local solr runStarted solr in local via these commands:./gradlew dev
export SOLR_OPTS="-Dsolr.security.allow.urls.enabled=false"
solr/packaging/build/dev/bin/solr startRan this dummy shard, which creates slow query tasks & thus, I can verify the V1 & V2 APIs. Took help of Gemini to figure this testing outpython3 -c "
import socket, time
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(('127.0.0.1', 9999))
server.listen(1)
print('📡 Raw socket listening on port 9999... Run your Solr query now!')
while True:
conn, addr = server.accept()
print('📥 Solr connected! Freezing connection for 2 seconds...')
time.sleep(2)
conn.close()
print('🔌 Connection released.')
"Actual VerificationFired these URLs to create solr query tasks:
List Task APIs Endpoints:
Get Task Status APIs Endpoints: |
|
@jaykay12 I got some AI help.... And there are some things that we need to improve. I'm going to try and summarize here, and then share the AI report below. I've gone through and edited/confirmed what the AI flagged!
Critical Issues 1. Distributed regression — cross-shard task aggregation is silently dropped The deleted // Only checks this shard's CancellableQueryTracker
solrQueryRequest.getCore().getCancellableQueryTracker().isQueryIdActive(taskID)In a distributed collection, a task running on shard 2 will be invisible to a client hitting shard 1's coordinator. The new implementation silently drops this cross-shard fan-out. 2. public enum TaskStatus {
ACTIVE("active"),
INACTIVE("inactive");
private final String value;
public String getValue() { return this.value; }
}Without @JsonValue
public String getValue() { return this.value; }3. V1 response format breaking change Old New boolean taskStatus = taskStatusResponse.taskStatus.equals(ACTIVE);
rsp.add("taskStatus", taskStatus); // true/false, not a stringThis breaks existing v1 clients that parse the old string format. The new integration tests also cast to Design Issues4. New tests may not be exercising the task status path
5. Solr's JAX-RS model convention uses kebab-case property names (e.g. @JsonProperty public String taskID; // "taskID" on the wire
@JsonProperty public String taskQuery; // "taskQuery" on the wireCompare to e.g. Minor Issues7. Unnecessary no-arg constructor in public ActiveTaskDetails() {} // Jackson doesn't need this — fields are publicRemove it; the parameterized constructor is sufficient for test/internal use, and Jackson can access public fields directly. 8. Unrelated change in The removal of the Javadoc line about 9. Verify that Test Coverage
Summary Table
|
The test method "testCrossShardTaskStatusVisibility" works on the main branch, but not on this branch.
… SOLR-18248-list-tasks








https://issues.apache.org/jira/browse/SOLR-18248
Description
Migrating 2 out of the 3 V2 APIs of Tasks, from existing homegrown annotations to JAX-RS Standard constructs & annotations
Solution
Have exposed 1 new interface: ListActiveTasksApi which serves the
/lists/taskas well as/list/task/<taskId>endpoints.ListActiveTasks is the main class which takes on the responsibility for v2 path as well as also for the v1 api path via ActiveTasksListHandler
2 new DTO for List Task API
1 new DTO for Task Status API
Removed the now deprecated files: ListActiveTasksAPI & ActiveTasksListComponent from the codebase.
No Coding Agent used.
Tests
Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.