Repository navigation
feat: get the PilotInfo in one query from PilotAgentsDB - #8779
Conversation
c4d527e to
1a65ad7
Compare
|
I am not fully sure to understand what you are trying to solve exactly here, can you provide further details please? I assume it's because of: DIRAC/src/DIRAC/WorkloadManagementSystem/Agent/PilotStatusAgent.py Lines 85 to 98 in 42c75a1 If it's the case, I am wondering why we don't just simplify by having a |
|
the problem is the query itself. select * from Table where column in (1,2,3,4,...,126456464)is not efficient. On the other hand, this is very fast create temporary table tmp_table(column INT PRIMARY KEY);
insert into tmp_table (column) values (1),(2),(3),(4),...,(126456464);
select * from table t join temporary table tt on t.column = tt.column;Of course, it's for large number of values. |
This I understand, but it looks like the query itself could be avoided by returning the pilot info instead of just the pilot reference from |
Apart from the call from the web, for which it might be true what you are saying, the general issue would still be there, right? @chaen when did you observe this? Which was the caller? |
|
IIRC the stalled job agent does a query like this? |
|
the problems were the site directors. I am happy with any change honestly, this was just an emergency fix |
|
I have changed the PR to just avoid the large IN by having 1 SQL request instead of 2. |
Add PilotAgentsDB.getPilotInfoForSelection, which returns the pilot information for a selectPilots-style condition in a single query, and attaches the jobs through a subquery on the same condition. SiteDirector and PilotStatusAgent used selectPilots followed by getPilotInfo on the returned references: above a few thousand references MySQL gives up the index on the IN list and scans the whole PilotAgents table. This replaces the temporary-table approach: getPilotInfo and getJobsForPilot go back to their previous behaviour (S_OK/S_ERROR contract, duplicate references tolerated). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5a10eac to
93d66ab
Compare
| if not result["OK"]: | ||
| return S_OK(resDict) |
There was a problem hiding this comment.
Are you sure?
If that's what you wanted, not even a warning here?
There was a problem hiding this comment.
I adjusted the function to done a single query instead of 2, the error is now returned to the caller
The jobs were selected in a second query that repeated the selection in a subquery: it was not atomic with the first one, sent a reference list twice and its failure was swallowed, leaving pilots without "Jobs" (PilotStatusAgent would then kill pilots with running jobs). - select the pilots in a derived table and LEFT JOIN JobToPilotMapping on it - return the error instead of S_OK without "Jobs" - getPilotInfoForSelection: add orderAttribute and limit, type hints - getPilotInfo: paramNames defaults to None Assisted-by: Claude:claude-opus-5-5
BEGINRELEASENOTES
*WMS
CHANGE: select pilot info in a single query instead of a large IN list and 2 queries
ENDRELEASENOTES