microsoft / vscode-cosmosdb

Azure Databases extension for VS Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-cosmosdb
MIT License
155 stars 69 forks source link

trying to run a mongo query fails with Timeout #852

Closed smv-orrin closed 5 years ago

smv-orrin commented 6 years ago

Repro steps:

Action: cosmosDB.executeMongoCommand Error type: string Error Message: Timed out executing MongoDB command "db.ingestion_queue.aggregate([{$match:{$and:[{"date_intended":{$gte:ISODate("2018-10-04")}},{"date_intended":{$lt:ISODate("2018-10-09")}}]}},{$project:{"_id":0,"date_intended":{$dateToString:{"date":"$date_intended","format":"%Y-%m-%d"}},"hr":{$hour:"$date_time"}}},{$group:{"_id":{"dt":"$date_intended","hr":"$hr"},"hourCt":{$sum:1}}},{$project:{"_id":0,"dt":"$_id.dt","hr":"$_id.hr","hourCt":"$hourCt"}},{$sort:{"dt":1,"hr":1}}])" Version: 0.8.0 OS: win32
StephenWeatherford commented 6 years ago

@smv-orrin Is it possible it really is hitting a timeout? (We have a small class of bugs we're working on where we're getting an incorrect time-out... From quick inspection this bug doesn't seem to be in that category.)

smv-orrin commented 6 years ago

This is a real bug. Before I submitted the ticket, I confirmed the issue by running the same query in: A) the mongo cli in a terminal window, and B) VS Code the mongo cli successfully returned results in a couple of seconds, VSCode failed with a TImeout

smv-orrin commented 6 years ago

Sorry, forgot to mention, just confirmed it again by testing the same query in both the mongo cli (terminal) and VSCode, with the same results - cli succeeded, vscode failed.

StephenWeatherford commented 6 years ago

@smv-orrin Thanks. How long does the query take to execute in mongo console?

smv-orrin commented 6 years ago

couple of seconds I tried attaching a video so you could see that the cli was returning quickly, but I can't attach a video it seems. I also don't see my comment history on this issue, I remember taking a closer look at this and noticing that it seemed to be tied to my use of the $hour function. When I comment out the $hour function (and replace with a straight-up integer), the query runs in VSCode without issue.

smv-orrin commented 6 years ago

so, long story short, if I use $hour() (as below) it fails with a timeout, if I give it a fake hour it works:

                "_id":0,
                "date_intended": {
                    $dateToString:{"date":"$date_intended","format":"%Y-%m-%d"}
                },
                "hr":{$hour:"$date_time"}
            }
StephenWeatherford commented 6 years ago

Are you using the emulator by any chance?

StephenWeatherford commented 6 years ago

838 ?

smv-orrin commented 6 years ago

Hey - not sure what you're asking... I'm not using any emulator that I'm aware of... I'm using the Azure Cosmos DB Extension against a real mongo DB server (running Mongo 3.6). I also have the mongo cli installed locally

StephenWeatherford commented 6 years ago

We support attaching to the COSMOSDB emulator (Mongo or SQL), just needed to rule that out, thanks.

pspkshah commented 5 years ago

is there any update on this issue,

"Timed out executing MongoDB command "use [DBName]"

Extension name: Azure Cosmos DB IDE: Visual Studion Code

Is anyone knows source code url on github for the extension, and way to dubug the same.

StephenWeatherford commented 5 years ago

@pspkshah, @smv-orrin This is weird. I can't repro it with the original query. We have seen "timeout" incorrectly reported as the error in some cases when the real error is not getting picked up properly (there's a P1 task scheduled in an upcoming release to rewrite the code responsible for spawning (https://github.com/Microsoft/vscode-cosmosdb/issues/838), but we've also fixed all the known ways of getting into this issue in the first place. It looks like this is probably hitting another one.

Could you try an experimental version that may report better errors? Download https://dev.azure.com/ms-azuretools/_apis/resources/Containers/2511844?itemPath=vsix%2Fvscode-cosmosdb-0.9.2-alpha.vsix, then use command palette -> Extensions: Install from VSIX... to install it. Please let us know what errors you get from the query.

Thanks! Stephen

~ BTW, you're more than welcome to explore our code and/or debug yourself, let us know if you have questions. You can find our repro from vscode, or else by clicking on Report Issue on an error dialog: image

StephenWeatherford commented 5 years ago

(Edited: I can't repro it with the original query)

StephenWeatherford commented 5 years ago

(Edited link: the original link doesn't work if you're not logged in.)

pspkshah commented 5 years ago

@pspkshah, @smv-orrin This is weird. I can't repro it with the original query. We have seen "timeout" incorrectly reported as the error in some cases when the real error is not getting picked up properly (there's a P1 task scheduled in an upcoming release to rewrite the code responsible for spawning (#838), but we've also fixed all the known ways of getting into this issue in the first place. It looks like this is probably hitting another one.

Could you try an experimental version that may report better errors? Download https://dev.azure.com/ms-azuretools/_apis/resources/Containers/2511844?itemPath=vsix%2Fvscode-cosmosdb-0.9.2-alpha.vsix, then use command palette -> Extensions: Install from VSIX... to install it. Please let us know what errors you get from the query.

Thanks! Stephen

~ BTW, you're more than welcome to explore our code and/or debug yourself, let us know if you have questions. You can find our repro from vscode, or else by clicking on Report Issue on an error dialog: image

I am getting below error while tried accesing above link

{"$id":"1","innerException":null,"message":"TF400813: The user 'Windows Live ID\xxx@xxx.com' is not authorized to access this resource.","typeName":"Microsoft.TeamFoundation.Framework.Server.UnauthorizedRequestException, Microsoft.TeamFoundation.Framework.Server","typeKey":"UnauthorizedRequestException","errorCode":0,"eventId":3000}

My Email address is not authrized on the mentioned URL. Please give access or make it open seperate latest branch for all

StephenWeatherford commented 5 years ago

Sorry, thought I'd corrected that link. It should be https://dev.azure.com/ms-azuretools/AzCode/_build/results?buildId=2476, then you have to click on Artifacts->vsix image

StephenWeatherford commented 5 years ago

@pspkshah @smv-orrin I'd love to hear if anyone tried the experimental build (it's easy to uninstall afterwards and reinstall the current version), and could let me know if they see more helpful error messages.

The link is here: https://dev.azure.com/ms-azuretools/AzCode/_build/results?buildId=2476 Instructions are here: https://github.com/Microsoft/vscode-azuretools/wiki/Install-Insiders-Build

Thanks! Stephen

pspkshah commented 5 years ago

Hi All, just update your VS Code Cosmos db extension with latest version. This issue take care and no more exist. I just updated with latest version and time out error is not coming.

StephenWeatherford commented 5 years ago

Thanks for letting us know.