-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Azure cosmos diagnostics memory leak fix #28343
Azure cosmos diagnostics memory leak fix #28343
Conversation
API change check for API changes have been detected in API changes + @Warning public static CosmosDiagnostics createCosmosDiagnostics(DiagnosticsClientContext diagnosticsClientContext)
- @Warning public static CosmosDiagnostics createCosmosDiagnostics(DiagnosticsClientContext diagnosticsClientContext, GlobalEndpointManager globalEndpointManager)
- @Warning public static void recordGatewayResponse(CosmosDiagnostics cosmosDiagnostics, RxDocumentServiceRequest rxDocumentServiceRequest, StoreResponse storeResponse, CosmosException exception)
- @Warning public static void recordResponse(CosmosDiagnostics cosmosDiagnostics, RxDocumentServiceRequest request, StoreResult storeResult)
+ @Warning public static void recordGatewayResponse(CosmosDiagnostics cosmosDiagnostics, RxDocumentServiceRequest rxDocumentServiceRequest, StoreResponse storeResponse, CosmosException exception, GlobalEndpointManager globalEndpointManager)
+ @Warning public static void recordResponse(CosmosDiagnostics cosmosDiagnostics, RxDocumentServiceRequest request, StoreResult storeResult, GlobalEndpointManager globalEndpointManager) |
/azp run java - cosmos - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
.../azure-cosmos/src/main/java/com/azure/cosmos/implementation/ClientSideRequestStatistics.java
Show resolved
Hide resolved
...cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/AddressSelector.java
Outdated
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosException.java
Show resolved
Hide resolved
...e-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/StoreResponse.java
Show resolved
Hide resolved
/azp run java - cosmos - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run java - cosmos - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
...ure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/StoreResult.java
Outdated
Show resolved
Hide resolved
...ure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/StoreResult.java
Outdated
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosException.java
Show resolved
Hide resolved
/azp run java - cosmos - tests |
Pull request contains merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -15,4 +16,6 @@ Mono<AddressInformation[]> resolveAsync( | |||
boolean forceRefreshPartitionAddresses); | |||
|
|||
int updateAddresses(URI serverKey); | |||
|
|||
GlobalEndpointManager getGlobalEndpointManager(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can discuss when you are in the office - I don't quite get why we would need to expose the GlobalEndpointManager here? There should only be one instance of it - why keep the reference in the AddressResolver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, worth discussing.
@@ -33,7 +32,7 @@ public static HttpClient getOrCreateInstance(HttpClientConfig httpClientConfig, | |||
} | |||
|
|||
counter.incrementAndGet(); | |||
diagnosticsClientConfig.withGatewayHttpClientConfig(sharedGatewayHttpClient.effectiveHttpClientConfig); | |||
diagnosticsClientConfig.withGatewayHttpClientConfig(httpClientConfig.toDiagnosticsString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use sharedGatewayHttpClient.effectiveHttpClientConfig.toDiagnosticsString()
Any possibility that we are using a different httpClientConfig through out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the effectiveHttpClientConfig
from SharedGatewayHttpClient
class as it was referencing the same thing. Worth taking another look.
jsonGenerator.flush(); | ||
ObjectNode objectNode = (ObjectNode) objectMapper.readTree(jsonWriter.toString()); | ||
|
||
assertThat(objectNode.get("id").asInt()).isEqualTo(1); | ||
assertThat(objectNode.get("machineId").asText()).isEqualTo(machineId); | ||
assertThat(objectNode.get("numberOfClients").asInt()).isEqualTo(2); | ||
assertThat(objectNode.get("consistencyCfg").asText()).isEqualTo("(consistency: null, mm: false, prgns: [])"); | ||
assertThat(objectNode.get("consistencyCfg").asText()).isEqualTo("(consistency: null, mm: false, prgns: [null])"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will discuss offline, had to change the default preferredRegions to null string if empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
/azp run java - cosmos - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run java - cosmos - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changelog entries for azure-cosmos and both spark versions are missing - otherwise LGTM
Problems ->
CosmosDiagnostics
contains reference tostoreResponseStatistics
which contains reference toStoreResponse
which containsCosmosDiagnostics
hence creating a circular dependency inCosmosDiagnostics
CosmosDiagnostics
contains reference toStoreResponse
- with full byte[] content, never freeing up those byte[] content even after the response has been received from the service.storeResponse
with full byte[] of contents.CosmosDiagnostics
contains reference toGlobalEndpointManager
which contains reference to some caches, schedulers, ExecutorService, and various other things, which makes it difficult for JVM to collect garbage diagnostics or responses.CosmosException
refers toCosmosDiagnostics
, which refers toDiagnosticsClientContext
which is actually a reference toRxDocumentClientImpl
- which exposes all information include caches, Store Models, and what not.Solution ->
CosmosDiagnostics
fromStoreResponse
as it is not required there.CosmosResponse
types, movedCosmosDiagnostics
toRxDocumentServiceResponse
initializing during creation of response.StoreResponse
,StoreResult
, andCosmosException
, and performing a deep copy with only instance members required for diagnostics.GlobalEndpointManager
reference fromCosmosDiagnostics
and just passed it around for capturingregionsContacted
DiagnosticsClientConfig
inCosmosDiagnostics
- which is only for configs serialization.