You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@yunikorn.apache.org by "YUNG_CHENG (Jira)" <ji...@apache.org> on 2026/10/29 12:09:00 UTC

[jira] [Created] (YUNIKORN-3540) Application.GetAllPlaceholderData() returns the internal PlaceholderData objects

YUNG_CHENG created YUNIKORN-3540:
------------------------------------

             Summary: Application.GetAllPlaceholderData() returns the internal PlaceholderData objects
                 Key: YUNIKORN-3540
                 URL: https://issues.apache.org/jira/browse/YUNIKORN-3540
             Project: Apache YuniKorn
          Issue Type: Bug
          Components: core - scheduler
            Reporter: YUNG_CHENG
            Assignee: YUNG_CHENG



{{Application.GetAllPlaceholderData()}} in {{pkg/scheduler/objects/application.go}} takes the application read lock and returns the {{*PlaceholderData}} pointers stored in the application. The lock is released when the method returns, but the caller still holds the internal objects.

The REST handler {{getPlaceholderDAO()}} in {{pkg/webservice/handlers.go}} reads {{Count}}, {{Replaced}} and {{TimedOut}} from these objects without the application lock. The scheduler changes the same fields under the application lock in {{addPlaceholderData()}}, {{removeAllocationInternal()}}, {{RemoveAllAllocations()}}, {{timeoutPlaceholderProcessing()}} and {{SetTimedOutPlaceholder()}}. This is a data race: a test that adds placeholder asks while it reads the data the same way as the REST handler fails with {{-race}}.

The impact is low. The REST response can show counts from the middle of an update, and the race detector reports the race. Because the caller gets the internal objects, a write through the returned pointer would also change the application state. No caller writes to it today.

The test variable in {{TestAddAllocAsk}} is called {{clonePlaceholderData}}, which suggests that the method was meant to return a copy.

*Proposed change*
Return a copy of each {{PlaceholderData}}. A shallow copy is enough: {{MinResource}} is cloned when the entry is created and is not changed afterwards. Update {{TestAddAllocAsk}} to compare the values instead of the pointers, and check that the result is a copy.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: issues-help@yunikorn.apache.org