Closed marc-sensenich closed 5 years ago
Thanks Marc for reporting the problem !! Is this blocking or silent exception with everything goes through as expected or if other things fail too?
It lets other operations complete if followed after initializing the client, see the code block below for reproduction. But will log the exception and occur the network cost of trying to refresh the location cache.
String permissionJSON = "{ \n" +
" \"id\": \"a_permission\", \n" +
" \"permissionMode\": \"Read\", \n" +
" \"resource\": \"dbs/volcanodb/colls/volcano1\", \n" +
" \"_rid\": \"Sl8fAG8cXgBn6Ju2GqNsAA==\", \n" +
" \"_ts\": 1449604760, \n" +
" \"_self\": \"dbs\\/Sl8fAA==\\/users\\/Sl8fAG8cXgA=\\/permissions\\/Sl8fAG8cXgBn6Ju2GqNsAA==\\/\", \n" +
" \"_etag\": \"\\\"00000e00-0000-0000-0000-566736980000\\\"\", \n" +
" \"_token\": \"type=resource&ver=1&sig=ocPyc9QQFybITu1EqzX0kg==;w+WR1aWafB3+yZq5JSoBwgz78XDlU+k9Xiqvc+Q7TlAl1P4h4t721Cn5cjhZ9h3TSd2\\/MJLy+wG+YkhDL9UlGkVv05RZGy2fMaLGdeQkWc7TShkc\\/M2boPc3GXq2yiERKl5CN4AZWSOcrFhOFuuTOqF4ZdBlflmNudaakodr\\/8qTip0i+a7moz1Jkc5+9iLAsDFyqTR1sirp7kAVNFbiqPdYTjNkvZUHF3nYYmRskOg=;\" \n" +
"} ";
String cosmosDBURL = "[your host]";
Permission thePermission = new Permission(permissionJSON);
AsyncDocumentClient limitedDocumentClient = new AsyncDocumentClient.Builder()
.withConnectionPolicy(ConnectionPolicy.GetDefault())
.withConsistencyLevel(ConsistencyLevel.Strong)
.withServiceEndpoint(cosmosDBURL)
.withPermissionFeed(new ArrayList<>(Arrays.asList(thePermission)))
.build();
String collectionLink = "dbs/integration-testing/colls/integration-testing-collection";
limitedDocumentClient.readCollection(collectionLink, null).toBlocking().first().getResource();
Thanks Marc !! We are get the new release by early next week with the fix , in mean time would you mind using withMasterKeyOrResourceToken instead of withPermissionFeed . Thanks again for your patience.
Thanks @simplynaveen20! Looking forward to the fix
Hi @simplynaveen20 , I work with @marc-sensenich . I wanted to follow up to make sure your fix would address this issue as well. Yesterday we were attempting to failover locations while reading and writing documents. The azure-cosmosdb library had some helpful log messages indicating inability to reach the gateway server, but the thrown exception itself matches the one in this ticket, making it difficult to catch and identify accurately. If this is considered a different problem I'll create a new issue for it. Thanks!
My logger config file didnt have the correct format, so the client library logs dont have timestamp/etc, but you can see the messages. Apologies for that.
RequestStartTime: 2019-01-14T22:13:28.6848000Z, Number of regions attempted: 1
, SDK: Microsoft.Azure.Documents.Common/2.1.0.0, StatusCode: Forbidden, responseHeaders={content-length=501, x-ms-last-state-change-utc=Mon, 14 Jan 2019 20:09:33.908 GMT, x-ms-current-replica-set-size=4, Server=Microsoft-HTTPAPI/2.0, x-ms-session-token=0:15#1104#1=1094, lsn=1104, x-ms-schemaversion=1.6, x-ms-transport-request-id=1437, x-ms-number-of-read-regions=1, x-ms-current-write-quorum=3, x-ms-cosmos-quorum-acked-llsn=1102, x-ms-quorum-acked-lsn=1104, x-ms-activity-id=6dcaebb0-0cf5-4570-8abb-409a10783332, Date=Mon, 14 Jan 2019 22:13:27 GMT, x-ms-xp-role=4, Strict-Transport-Security=max-age=31536000, x-ms-global-Committed-lsn=1104, x-ms-cosmos-llsn=1102, x-ms-gatewayversion=version=2.1.0.0, x-ms-serviceversion=version=2.1.0.0, Content-Type=application/json, x-ms-substatus=3}}
marking the endpoint https://bnr-marc-sensenich-testing.documents.azure.com:443/ as unavailable for write
Getting database account endpoint from https://bnr-marc-sensenich-testing.documents.azure.com:443/
Fail to reach global gateway [https://bnr-marc-sensenich-testing.documents.azure.com:443/], [Invalid resource id ]
java.lang.IllegalArgumentException: Invalid resource id
at com.microsoft.azure.cosmosdb.internal.ResourceId.parse(ResourceId.java:75)
at com.microsoft.azure.cosmosdb.internal.ResourceTokenAuthorizationHelper.getAuthorizationTokenUsingResourceTokens(ResourceTokenAuthorizationHelper.java:161)
at com.microsoft.azure.cosmosdb.rx.internal.RxDocumentClientImpl.getUserAuthorizationToken(RxDocumentClientImpl.java:1057)
at com.microsoft.azure.cosmosdb.rx.internal.RxDocumentClientImpl.populateHeaders(RxDocumentClientImpl.java:1022)
at com.microsoft.azure.cosmosdb.rx.internal.RxDocumentClientImpl.lambda$getDatabaseAccountFromEndpoint$144(RxDocumentClientImpl.java:3042)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
at rx.Observable.unsafeSubscribe(Observable.java:10327)
at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
at rx.Observable.unsafeSubscribe(Observable.java:10327)
at rx.internal.operators.OnSubscribeSingle.call(OnSubscribeSingle.java:81)
at rx.internal.operators.OnSubscribeSingle.call(OnSubscribeSingle.java:27)
at rx.Single.subscribe(Single.java:1979)
at rx.internal.operators.SingleOperatorOnErrorResumeNext.call(SingleOperatorOnErrorResumeNext.java:77)
at rx.internal.operators.SingleOperatorOnErrorResumeNext.call(SingleOperatorOnErrorResumeNext.java:23)
at rx.Single.subscribe(Single.java:1979)
at rx.internal.operators.SingleOnSubscribeMap.call(SingleOnSubscribeMap.java:45)
at rx.internal.operators.SingleOnSubscribeMap.call(SingleOnSubscribeMap.java:30)
at rx.Single.subscribe(Single.java:1979)
at rx.internal.operators.CompletableFlatMapSingleToCompletable.call(CompletableFlatMapSingleToCompletable.java:43)
at rx.internal.operators.CompletableFlatMapSingleToCompletable.call(CompletableFlatMapSingleToCompletable.java:28)
at rx.Completable.unsafeSubscribe(Completable.java:2035)
at rx.Completable$5.call(Completable.java:398)
at rx.Completable$5.call(Completable.java:379)
at rx.Completable.unsafeSubscribe(Completable.java:2035)
at rx.Completable$19.call(Completable.java:1365)
at rx.Completable$19.call(Completable.java:1362)
at rx.Completable.unsafeSubscribe(Completable.java:2035)
at rx.Completable$5.call(Completable.java:398)
at rx.Completable$5.call(Completable.java:379)
at rx.Completable.unsafeSubscribe(Completable.java:2035)
at rx.Completable.unsafeSubscribe(Completable.java:2083)
at rx.Completable.unsafeSubscribe(Completable.java:2067)
at rx.Completable$32.call(Completable.java:2253)
at rx.Completable$32.call(Completable.java:2250)
at rx.Observable.subscribe(Observable.java:10423)
at rx.Observable.subscribe(Observable.java:10390)
at rx.internal.operators.SingleOnSubscribeDelaySubscriptionOther.call(SingleOnSubscribeDelaySubscriptionOther.java:87)
at rx.internal.operators.SingleOnSubscribeDelaySubscriptionOther.call(SingleOnSubscribeDelaySubscriptionOther.java:29)
at rx.internal.operators.SingleToObservable.call(SingleToObservable.java:39)
at rx.internal.operators.SingleToObservable.call(SingleToObservable.java:27)
at rx.Observable.unsafeSubscribe(Observable.java:10327)
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48)
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.Observable.unsafeSubscribe(Observable.java:10327)
at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:248)
at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:148)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77)
at rx.internal.operators.OnSubscribeRedo$3$1.onNext(OnSubscribeRedo.java:302)
at rx.internal.operators.OnSubscribeRedo$3$1.onNext(OnSubscribeRedo.java:284)
at rx.internal.operators.NotificationLite.accept(NotificationLite.java:135)
at rx.subjects.SubjectSubscriptionManager$SubjectObserver.emitNext(SubjectSubscriptionManager.java:253)
at rx.subjects.BehaviorSubject.onNext(BehaviorSubject.java:160)
at rx.observers.SerializedObserver.onNext(SerializedObserver.java:91)
at rx.subjects.SerializedSubject.onNext(SerializedSubject.java:67)
at rx.internal.operators.OnSubscribeRedo$2$1.onError(OnSubscribeRedo.java:237)
at rx.internal.operators.SingleLiftObservableOperator$WrapSubscriberIntoSingle.onError(SingleLiftObservableOperator.java:81)
at rx.internal.operators.OnSubscribeSingle$1.onError(OnSubscribeSingle.java:64)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onError(OnSubscribeMap.java:88)
at rx.internal.operators.OperatorMerge$MergeSubscriber.reportError(OperatorMerge.java:266)
at rx.internal.operators.OperatorMerge$MergeSubscriber.checkTerminate(OperatorMerge.java:818)
at rx.internal.operators.OperatorMerge$MergeSubscriber.emitLoop(OperatorMerge.java:579)
at rx.internal.operators.OperatorMerge$MergeSubscriber.emit(OperatorMerge.java:568)
at rx.internal.operators.OperatorMerge$InnerSubscriber.onError(OperatorMerge.java:855)
at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onError(OnSubscribeMap.java:88)
at rx.internal.operators.OperatorMerge$MergeSubscriber.reportError(OperatorMerge.java:266)
at rx.internal.operators.OperatorMerge$MergeSubscriber.checkTerminate(OperatorMerge.java:818)
at rx.internal.operators.OperatorMerge$MergeSubscriber.emitLoop(OperatorMerge.java:579)
at rx.internal.operators.OperatorMerge$MergeSubscriber.emit(OperatorMerge.java:568)
at rx.internal.operators.OperatorMerge$InnerSubscriber.onError(OperatorMerge.java:855)
at rx.internal.operators.OperatorMerge$MergeSubscriber.reportError(OperatorMerge.java:266)
at rx.internal.operators.OperatorMerge$MergeSubscriber.checkTerminate(OperatorMerge.java:818)
at rx.internal.operators.OperatorMerge$MergeSubscriber.emitLoop(OperatorMerge.java:579)
at rx.internal.operators.OperatorMerge$MergeSubscriber.emit(OperatorMerge.java:568)
at rx.internal.operators.OperatorMerge$InnerSubscriber.onError(OperatorMerge.java:855)
at rx.internal.operators.OnSubscribeThrow.call(OnSubscribeThrow.java:44)
at rx.internal.operators.OnSubscribeThrow.call(OnSubscribeThrow.java:28)
at rx.Observable.unsafeSubscribe(Observable.java:10327)
at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:248)
at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:148)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77)
at rx.internal.operators.DeferredScalarSubscriber.complete(DeferredScalarSubscriber.java:100)
at rx.internal.operators.DeferredScalarSubscriber.onCompleted(DeferredScalarSubscriber.java:73)
at io.reactivex.netty.protocol.http.UnicastContentSubject$AutoReleaseByteBufOperator$1.onCompleted(UnicastContentSubject.java:260)
at rx.internal.operators.BufferUntilSubscriber.onCompleted(BufferUntilSubscriber.java:156)
at io.reactivex.netty.protocol.http.UnicastContentSubject.onCompleted(UnicastContentSubject.java:282)
at io.reactivex.netty.protocol.http.client.ClientRequestResponseConverter$ResponseState.sendOnComplete(ClientRequestResponseConverter.java:413)
at io.reactivex.netty.protocol.http.client.ClientRequestResponseConverter$ResponseState.access$500(ClientRequestResponseConverter.java:350)
at io.reactivex.netty.protocol.http.client.ClientRequestResponseConverter.channelRead(ClientRequestResponseConverter.java:168)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284)
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1389)
at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1159)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1203)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
at io.reactivex.netty.metrics.BytesInspector.channelRead(BytesInspector.java:59)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.reactivex.netty.pipeline.InternalReadTimeoutHandler.channelRead(InternalReadTimeoutHandler.java:108)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1414)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:945)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:146)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Hi @John20001 / @marc-sensenich - Please try both the issues with version 2.3.1
@simplynaveen20 this code has been tested by @John20001 and I. This resolves the issues we were encountering and I am going to close the issue.
Glad to hear that , thank you again for actively working on it , let us know if you face any other problem.
Describe the issue When building an AsyncDocumentClient using
.withPermissionFeed
the application emits error logs regarding failures for reading the Database AccountTo Reproduce Create an AsyncDocumentClient using a code block similar to
Expected behavior
The Database Account is read and the LocationCache is updated.
Actual behavior The Database Account can not be read and the error logs are emitted due to an error parsing the ResourceId provided, which is an empty string.
Environment summary SDK Version: 2.3.1 Java JDK version: 1.8 OS Version (e.g. Windows, Linux, MacOSX): Linux
Additional context I've validated this action with 2 ResourceTokens, one granted
Read
access to a collection and one grantedAll
access to a collection.