From e8b1fdf65f09bff597764a3e64cdbb5b8230203b Mon Sep 17 00:00:00 2001 From: Aayush Kataria Date: Thu, 4 Sep 2025 07:25:06 -0700 Subject: [PATCH] =?UTF-8?q?Revert=20"Hybrid=20Search:=20Adding=20fixes=20f?= =?UTF-8?q?or=20schedulingStopWatch=20start/stop=20for=20a=20=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit be822278c36aef639e29351715879a7d649af6b5. --- sdk/cosmos/azure-cosmos/CHANGELOG.md | 1 - .../query/metrics/SchedulingStopwatch.java | 24 +++++-------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/CHANGELOG.md b/sdk/cosmos/azure-cosmos/CHANGELOG.md index ae15f048e8a2..2b915b75886e 100644 --- a/sdk/cosmos/azure-cosmos/CHANGELOG.md +++ b/sdk/cosmos/azure-cosmos/CHANGELOG.md @@ -12,7 +12,6 @@ * Fixed Null Pointer Exception for query when container recreated with same name. - [PR 45930](https://github.com/Azure/azure-sdk-for-java/pull/45930) * Fixed Null Pointer Exception for readMany when container recreated with same name. - [PR 45930](https://github.com/Azure/azure-sdk-for-java/pull/45930) * Fixed parameterized query failures for Hybrid Search queries. - [PR 46446](https://github.com/Azure/azure-sdk-for-java/pull/46446) -* Fixed a rare race in parallel Hybrid Search queries by making internal SchedulingStopwatch start/stop atomic and idempotent. - [PR 46485](https://github.com/Azure/azure-sdk-for-java/pull/46485) #### Other Changes * Added change to optimize lease checkpointing in `ChangeFeedProcessor` by conditionally executing checkpoint operations for 304 responses based on continuation token comparison, which helps to reduce RU consumption for unchanged feeds. See [PR 46521](https://github.com/Azure/azure-sdk-for-java/pull/46521) diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/metrics/SchedulingStopwatch.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/metrics/SchedulingStopwatch.java index 1ad159e9addd..8e6e5957c593 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/metrics/SchedulingStopwatch.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/metrics/SchedulingStopwatch.java @@ -26,7 +26,7 @@ public SchedulingTimeSpan getElapsedTime() { /** * Tells the SchedulingStopwatch know that the process is in a state where it is ready to be worked on, - * which in turn starts the stopwatch for response time and turnaround time. + * which in turn starts the stopwatch for for response time and turnaround time. */ public void ready() { startStopWatch(this.turnaroundTimeStopwatch); @@ -34,26 +34,20 @@ public void ready() { } public void start() { - synchronized (this.runTimeStopwatch) { - if (this.runTimeStopwatch.isStarted()) { - return; - } + if (!this.runTimeStopwatch.isStarted()) { if (!this.responded) { // This is the first time the process got a response, so the response time stopwatch needs to stop. - stopStopWatch(this.responseTimeStopwatch); + this.responseTimeStopwatch.stop(); this.responded = true; } this.runTimeStopwatch.reset(); - this.runTimeStopwatch.start(); + startStopWatch(this.runTimeStopwatch); } } public void stop() { - synchronized (this.runTimeStopwatch) { - if (!this.runTimeStopwatch.isStarted()) { - return; - } - this.runTimeStopwatch.stop(); + if (this.runTimeStopwatch.isStarted()) { + stopStopWatch(this.runTimeStopwatch); this.numPreemptions++; } } @@ -65,18 +59,12 @@ public void terminate() { private void startStopWatch(StopWatch stopwatch) { synchronized (stopwatch) { - if (stopwatch.isStarted()) { - return; // idempotent start - } stopwatch.start(); } } private void stopStopWatch(StopWatch stopwatch) { synchronized (stopwatch) { - if (!stopwatch.isStarted()) { - return; // idempotent stop - } stopwatch.stop(); } }