Skip to content
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

Reduce of empty array with no initial value #108

Open
Nalum opened this issue Feb 8, 2016 · 9 comments
Open

Reduce of empty array with no initial value #108

Nalum opened this issue Feb 8, 2016 · 9 comments
Labels

Comments

@Nalum
Copy link

Nalum commented Feb 8, 2016

Running the following on MongoDB 3.0.8 worked (I think I may have also been using an older version of the shell command): mongo --host localhost --eval "var collection = 'events', query = {'title': 'event title'};" database variety.js

The collection I'm querying has over 15 million documents in it. At the time that it worked it had between 12 and 13 million documents. If I run the query on the database and get a count there are ~350 documents.

We have recently upgraded to MongoDB 3.0.9 and running the same command gives the below output:

MongoDB shell version: 3.2.1
connecting to: localhost:27017/database
Variety: A MongoDB Schema Analyzer
Version 1.5.0, released 14 May 2015
Cannot use 'commands' readMode, degrading to 'legacy' mode
Using collection of "events"
Using query of { "title" : "event title" }
Using limit of 0
Using maxDepth of 99
Using sort of { "_id" : -1 }
Using outputFormat of "ascii"
Using persistResults of false
Using resultsDatabase of "varietyResults"
Using resultsCollection of "eventsKeys"
Using resultsUser of null
Using resultsPass of null
Using plugins of [ ]
2016-02-08T21:29:05.740+0000 E QUERY    [thread1] TypeError: reduce of empty array with no initial value :
createAsciiTable@variety.js:333:19
@variety.js:365:10
@variety.js:12:2

failed to load: variety.js

If there is anything else I can provide let me know.

@todvora
Copy link
Contributor

todvora commented Feb 10, 2016

Hi Luke,
Thank you for your bugreport! I'll try to replicate and fix this issue.

Everyone: maybe it's time to integrate some Docker magic, to be able to test on several different MongoDB versions...

Regards,
Tomas

@JamesCropcho
Copy link
Member

Tomáš,

Now that we've got this Docker stuff mostly figured out, are you able to reproduce Luke's issue or not so much?

James

@todvora
Copy link
Contributor

todvora commented Feb 17, 2016

Hi James,
Unfortunately not, not with the current test suite. I am still looking for the cause of this issue.

Regards,
Tomas

@JamesCropcho
Copy link
Member

Luke,

Please pardon—we don't seem able to reproduce. Are you still experience this issue? Any insight it weirdness of this collection which might cause an usual error? Or if not, that's fine, too; just trying to sleuth it out (ha).

James

@todvora
Copy link
Contributor

todvora commented Feb 19, 2016

Hi Luke,
It could be really helpful, if you could provide some minimized / anonymized collection to run tests against. Would it be possible?

It seems, that variety tries to print into the ascii table a row, which does not contain any values. But where is it come from... I could probably fix the consequence. But without knowing the original cause, it will bite us somewhere else next time.

Thanks,
Tomas

@Nalum
Copy link
Author

Nalum commented Feb 19, 2016

@todvora @JamesCropcho I'll try get a sample of data to you over the weekend. I'm gonna run it again myself and see how it goes. It is possible that some of the new data cased the issue.

@JamesCropcho
Copy link
Member

Luke and Tomáš, I'm going to close this ticket/issue for now. By all means please feel free to re-open when we get more information or insights. Hope you two are having a nice week. —James

@hdavidzhu
Copy link

Repro'ed. This happens when the query causes the db to not return any values. When the resulting array is empty [], we get this error.

@JamesCropcho JamesCropcho reopened this Apr 11, 2018
@JamesCropcho
Copy link
Member

Thank you for letting us know, David ( @hdavidzhu ). Wow, this sounds like it's likely quite a commonly encountered bug, and it's been around for two years! (Hence, our appreciation, once again.) I have re-opened the issue for consideration.

@todvora It's surprising that the test suite wouldn't catch this, at least if indeed happens any time the initial query to the target collection doesn't return values. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants