arunsarin85 opened a new pull request, #9889: URL: https://github.com/apache/ozone/pull/9889
…due to TOCTOU race in port selection ## What changes were proposed in this pull request? The upgrade tests (TestDatanodeUpgradeToSchemaV3, TestDatanodeUpgradeToHBaseSupport, TestDatanodeUpgradeToContainerIdsTable) used SCMTestUtils.getReuseableAddress() to pre-reserve a port for the mock SCM RPC server. This method opens a ServerSocket on port 0, reads the OS-assigned port, then immediately closes the socket - leaving a race window between the close and the subsequent bind in startScmRpcServer(). Under load, another process can grab that port in this window, causing a BindException. **Fix:** Replace the two-step reserve-then-bind with a single atomic bind by passing port 0 directly to startScmRpcServer(). The actual bound port is read back via RPC.Server.getListenerAddress() and written into the configuration before the DatanodeStateMachine is created, preserving the correct startup ordering. ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-14787 ## How was this patch tested? Verified with 20 consecutive runs of both the specific failing test (testAddHddsVolumeAfterFinalize) and the full TestDatanodeUpgradeToSchemaV3 class with 0 failures. [full_log_TestDatanodeUpgradeToSchemaV3_testAddHddsVolumeAfterFinalize_20260308_051513.txt](https://github.com/user-attachments/files/25820467/full_log_TestDatanodeUpgradeToSchemaV3_testAddHddsVolumeAfterFinalize_20260308_051513.txt) [summary_TestDatanodeUpgradeToSchemaV3_testAddHddsVolumeAfterFinalize_20260308_051513.txt](https://github.com/user-attachments/files/25820468/summary_TestDatanodeUpgradeToSchemaV3_testAddHddsVolumeAfterFinalize_20260308_051513.txt) [full_log_TestDatanodeUpgradeToSchemaV3_20260308_052543.txt](https://github.com/user-attachments/files/25820469/full_log_TestDatanodeUpgradeToSchemaV3_20260308_052543.txt) [summary_TestDatanodeUpgradeToSchemaV3_20260308_052543.txt](https://github.com/user-attachments/files/25820470/summary_TestDatanodeUpgradeToSchemaV3_20260308_052543.txt) -- 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]
