TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

MongoDB queries don’t always return all matching documents

444 pointsby dan_ahmadialmost 9 years ago

44 comments

im_down_w_otpalmost 9 years ago
Said it before, will say it again... &quot;MongoDB is the core piece of architectural rot in every single teetering and broken data platform I&#x27;ve worked with.&quot;<p>The fundamental problem is that MongoDB provides almost no stable semantics to build something deterministic and reliable on top of it.<p>That said. It is really, really easy to use.
评论 #11858393 未加载
评论 #11859084 未加载
评论 #11859851 未加载
评论 #11859808 未加载
评论 #11866909 未加载
评论 #11859260 未加载
评论 #11861737 未加载
评论 #11858902 未加载
lossoloalmost 9 years ago
I&#x27;ve just migrated one project from mongo to postgresql and i advise you to do the same. It was my mistake to use mongo, after I&#x27;ve found memory leak in cursors first day I&#x27;ve used the db which I&#x27;ve reported and they fixed it. It was 2015.. If you have a lot of relations in your data don&#x27;t use mongo, it&#x27;s just hype. You will end up with collections without relations and then do joins in your code instead of having db do it for you.
评论 #11858251 未加载
评论 #11857941 未加载
评论 #11858037 未加载
评论 #11858246 未加载
评论 #11861662 未加载
评论 #11858759 未加载
评论 #11858029 未加载
评论 #11858804 未加载
hardwaresoftonalmost 9 years ago
If you&#x27;re currently using MongoDB in your stack and are finding yourselves outgrowing it or worried that an issue like this might pop up, you owe it to yourself to check out RethinkDB:<p><a href="https:&#x2F;&#x2F;rethinkdb.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;rethinkdb.com&#x2F;</a><p>It&#x27;s quite possibly the best document store out right now. Many others in this thread have said good things about it, but give it a try and you&#x27;ll see.<p>Here&#x27;s a technical comparison of RethinkDB and Mongo: <a href="https:&#x2F;&#x2F;rethinkdb.com&#x2F;docs&#x2F;comparison-tables&#x2F;" rel="nofollow">https:&#x2F;&#x2F;rethinkdb.com&#x2F;docs&#x2F;comparison-tables&#x2F;</a><p>Here&#x27;s the aphyr review of RethinkDB (based on 2.2.3): <a href="https:&#x2F;&#x2F;aphyr.com&#x2F;posts&#x2F;330-jepsen-rethinkdb-2-2-3-reconfiguration" rel="nofollow">https:&#x2F;&#x2F;aphyr.com&#x2F;posts&#x2F;330-jepsen-rethinkdb-2-2-3-reconfigu...</a>
评论 #11859112 未加载
评论 #11861258 未加载
lathalmost 9 years ago
A lot of Mongo DB bashing on HA. We use it and I love it. Of course we have a dataset suited perfectly for Mongo - large documents with little relational data. We paid $0 and quickly and easily configured a 3 node HA cluster that is easy to maintain and performs great.<p>Remember, not all software needs to scale to millions of users so something affordable and easy to install, use, and maintain makes a lot of sense. Long story short, use the best tool for the job.
评论 #11860166 未加载
评论 #11861313 未加载
danbmil99almost 9 years ago
Oh, the fud of it.<p>The behavior is well documented here <a href="https:&#x2F;&#x2F;jira.mongodb.org&#x2F;browse&#x2F;SERVER-14766" rel="nofollow">https:&#x2F;&#x2F;jira.mongodb.org&#x2F;browse&#x2F;SERVER-14766</a><p>and in the linked issues. Seasoned users of mongodb know to structure their queries to avoid depending on a cursor if the collection may be concurrently updated by another process.<p>The usual pattern is to re-query the db in cases where your cursor may have gone stale. This tends to be habit due to the 10-minute cursor timeout default.<p>MongoDB may not be perfect, but like any tool, if you know its limitations it can be extremely useful, and it certainly is way more approachable for programmers who do not have the luxury of learning all the voodoo and lore that surrounds SQL-based relational DB&#x27;s.<p>Look for some rational discussion at the bottom of this mongo hatefest!
评论 #11861744 未加载
评论 #11863392 未加载
评论 #11862222 未加载
ahachetealmost 9 years ago
Strongly biased comment here, but hope its useful.<p>Have you tried ToroDB (<a href="https:&#x2F;&#x2F;github.com&#x2F;torodb&#x2F;torodb" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;torodb&#x2F;torodb</a>)? It still has a lot of room for improvement, but it basically gives you what MongoDB does (even the same API at the wire level) while transforming data into a relational form. Completely automatically, no need to design the schema. It uses Postgres, but it is far better than JSONB alone, as it maps data to relational tables and offers a MongoDB-compatible API.<p>Needless to say, queries and cursors run under REPEATABLE READ isolation mode, which means that the problem stated by OP will never happen here. Problem solved.<p>Please give it a try and contribute to its development, even just with providing feedback.<p>P.S. ToroDB developer here :)
评论 #11860663 未加载
cachemissalmost 9 years ago
My general feeling is that MongoDb was designed by people who hadn&#x27;t designed a database before, and marketed to people who didn&#x27;t know how to use one.<p>Its marketing was pretty silly about all the various things it would do, when it didn&#x27;t even have a reliable storage engine.<p>Its defaults at launch would consider a write stored when it was buffered for send on the client, which is nuts. There&#x27;s lots of ways to solve the problems that people use MongoDB for, without all of the issues it brings.
评论 #11861563 未加载
vegabookalmost 9 years ago
I have moved from Mongo to Cassandra in a financial time series context, and it&#x27;s what I should have done straight from the getgo. I don&#x27;t see Cassandra as that much more difficult to setup than Mongo, certainly no harder than Postgres IMHO, even in a cluster, and what you get leaves <i>everything</i> else in the dust if you can wrap your mind around its key-key-value store engine. It brings enormous benefits to a huge class of queries that are common in timeseries, logs, chats etc, and with it, no-single-point-of-failure robustness, and real-deal scalability. I literally saw a 20x performance improvement on range queries. Cannot recommend it more (and no, I have no affiliation to Datastax).
评论 #11858867 未加载
评论 #11862070 未加载
jsemraualmost 9 years ago
Weird to see that Mongo is still around. We started to use them on a project ~4 years ago. Easy install, but that&#x27;s where the problems started. Overall terrible experience. Low performance, Syntax a mess, unreadable documentation.<p>They seem to still have this outstanding marketing team.
paradox95almost 9 years ago
Should an infrastructure company be advertising the fact that it didn&#x27;t research the technology it chose to use to build its own infrastructure?<p>All these people saying Mongo is garbage are all likely neckbeards sysadmins. Unless you&#x27;re hiring database admin and sysadmins, Postgres (unless managed - then you have a different set of scaling problems) or any other tradition SQL store is not a viable alternative. This author uses Bigtable as a point of comparison. Stay tuned for his next blog post comparing IIS to Cloudflare.<p>Almost every blog post titled &quot;why we&#x27;re moving from Mongo to X&quot; or &quot;Top 10 reason to avoid Mongo&quot; could have been prevented with a little bit of research. People have spent their entire life working with the SQL world so throw something new at them and they reject it like the plague. Postgres is only good now because they had to do some of the features in order to compete with Mongo. Postgres been around since 1996 and you&#x27;re only now using it? Tell me more about how awesome it is.
评论 #11859022 未加载
ruw1090almost 9 years ago
While I love to hate on MongoDB as much as the next guy, this behavior is consistent with read-committed isolation. You&#x27;d have to be using Serializable isolation in an RDBMS to avoid this anomaly.
评论 #11858705 未加载
评论 #11858320 未加载
评论 #11858455 未加载
评论 #11858691 未加载
评论 #11858471 未加载
评论 #11859107 未加载
twundealmost 9 years ago
The real problem with Mongo is that it&#x27;s so enjoyable to start a project with that it&#x27;s easy to look for ways to continue using it even when Mongo&#x27;s problems start surfacing. I&#x27;ll never forget how many problems my team ended up facing with Mongo. Missing inserts, slow queries with only a few hundred records, document size limits. All while Mongo was paraded as web scale in talks.
wzyalmost 9 years ago
Does Meteor support a proper database system yet, a la. MySQL or Postgres?
评论 #11858311 未加载
aavotinsalmost 9 years ago
MongoDB reminds me of an old saying that if you have a problem and you use a regex to solve it, you end up with two problems.<p>I have personally used MongoDB in production two times for fairly busy and loaded projects, and both times I ended up to be the person that encouraged migrating away from MongoDB to a SQL based storage solution. Even at my current job there&#x27;s still evidence that MongoDB was used for our product, but eventually got migrated to PostgreSQL.<p>Most of the times I&#x27;ve thought that I chose the wrong tool for the right job, which may be true, but still leaves a lot of thought about the correct application. Right now I have a MongoDB anxiety - as soon as I start thinking about maybe using it(with an emphasis on maybe), I remember all the troubles I went through and just forget it.<p>It is certainly not a bad product, but it&#x27;s a niche product in my opinion. Maybe I just haven&#x27;t found the niche.
评论 #11861290 未加载
jtchangalmost 9 years ago
This single issue would make me not want to use MongoDB. I&#x27;m sure there are design considerations around it but I rather use something that has sane semantics around these edge cases.
Animatsalmost 9 years ago
Not when they&#x27;re changing rapidly, anyway. Well, that&#x27;s relaxed consistency for you.<p>Does this guy have so many containers running that the status info can&#x27;t be kept in RAM? I have a status table in MySQL that&#x27;s kept by the MEMORY engine; it&#x27;s thus in RAM. It doesn&#x27;t have to survive reboots.
fiatjafalmost 9 years ago
CouchDB is simple and reliable. You can understand it from day one. I can&#x27;t imagine why it isn&#x27;t being used.
评论 #11858881 未加载
评论 #11859131 未加载
avitalalmost 9 years ago
I believe this is solved by Mongo&#x27;s &quot;snapshot&quot; method on cursors: <a href="https:&#x2F;&#x2F;docs.mongodb.com&#x2F;v3.0&#x2F;faq&#x2F;developers&#x2F;#faq-developers-isolate-cursors" rel="nofollow">https:&#x2F;&#x2F;docs.mongodb.com&#x2F;v3.0&#x2F;faq&#x2F;developers&#x2F;#faq-developers...</a>
评论 #11858745 未加载
rjurneyalmost 9 years ago
Mongo is hilarious. Ease of use is so important, we just don&#x27;t much give a shit that it has all these gaping holes and flaws in it.
shruubialmost 9 years ago
Seriously, who looks at MongoDB and thinks &quot;this is a sane way of doing things&quot;?<p>To be fair, I&#x27;ve never been much of a fan of the whole NoSQL solution, so I may be biased, but what real benefits do you gain from using NoSQL over anything else?
评论 #11858765 未加载
评论 #11861811 未加载
d3ckardalmost 9 years ago
I worked with MongoDB quite a lot in context of Rails applications. While it has performance issues and can generally become pain because of lack of relations features, it also allows for really fast prototyping (and I believe that Mongoid is much nicer to work with than Active Record).<p>When you&#x27;re developing MVPs, work with ever changing designs and features, ability to cut off this whole migration part comes around really handy. I would however recommend to anybody to keep migration plan for the moment the product stabilizes. If you don&#x27;t, you end up in the world of pain.
hendzenalmost 9 years ago
Actually, if this lack of index update isolation is correct, you can get the matching document zero, one or <i>multiple times</i>!
doubleorsevenalmost 9 years ago
Mongo, in one word: sucks. Couchbase, does not.
评论 #11857813 未加载
评论 #11858122 未加载
评论 #11858409 未加载
spullaraalmost 9 years ago
It literally returns wrong answers for queries. I can&#x27;t believe anyone this thread is defending it.
jitixalmost 9 years ago
What storage engine are you using? I wonder if the same issue comes in wiredtiger MVCC engine.
评论 #11857908 未加载
alkonautalmost 9 years ago
So it&#x27;s a bit weak in the design department, offers a bit less rigid semantics than one might hope, and from the start it&#x27;s a technology that was almost a reaction to the rigid and enterprise-y of old.<p>Mongo reminds me a wee bit of JS...
xchaoticalmost 9 years ago
Unless you want to code every rdbms and enterprise feature in the application layer, don&#x27;t use Minho, use Postgres or Use Marklogic. It is &#x27;nosql&#x27;, but it is acid compliant and uses MVCC so what the queries return is predictable.
Osirisalmost 9 years ago
I hear a lot about MongoDB&#x27;s reliability issues. How do CouchDB or other document store database compare in terms of reliability and consistency?
评论 #11859155 未加载
clentaminatoralmost 9 years ago
An interesting read into the development of a project that started using MongoDB and switched to PostgreSQL after eight months in production: <a href="http:&#x2F;&#x2F;www.sarahmei.com&#x2F;blog&#x2F;2013&#x2F;11&#x2F;11&#x2F;why-you-should-never-use-mongodb&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.sarahmei.com&#x2F;blog&#x2F;2013&#x2F;11&#x2F;11&#x2F;why-you-should-never...</a>
partycoderalmost 9 years ago
This use-case is not something that you would use MongoDB for. Try Zookeeper.<p>This being said, I would feel embarrassed to post this on behalf of the engineering department of a company.<p>This post is just a very illustrated way of saying &quot;we have no idea about what we are doing and our services are completely unreliable&quot;.<p>This is so bad that is more of an HR problem than it is an engineering problem.
评论 #11858782 未加载
tinixalmost 9 years ago
Y&#x27;all know other storage engines exist, right?<p>I searched the comments for &quot;percona&quot; and found nothing...<p>Figures.<p>Meanwhile, <a href="https:&#x2F;&#x2F;github.com&#x2F;percona&#x2F;percona-server-mongodb&#x2F;pull&#x2F;17" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;percona&#x2F;percona-server-mongodb&#x2F;pull&#x2F;17</a>
bbcbasicalmost 9 years ago
Ahhh the Trough of Dissolutionment!<p>[1] <a href="https:&#x2F;&#x2F;setandbma.wordpress.com&#x2F;2012&#x2F;05&#x2F;28&#x2F;technology-adoption-shift&#x2F;" rel="nofollow">https:&#x2F;&#x2F;setandbma.wordpress.com&#x2F;2012&#x2F;05&#x2F;28&#x2F;technology-adopti...</a>
xenadu02almost 9 years ago
Use of MongoDB at PlanGrid is probably the single worst technical decision the company ever made.<p>We&#x27;ve migrated our largest collections to Postgres tables and our happiness with that decision increases by the day.
vs2370almost 9 years ago
I am pretty excited about cockroachDb. Its still in beta so not suggested for production use yet, but its being designed pretty carefully and by a great team.. check them out cockroachlabs.com
mouzogualmost 9 years ago
Is MongoDB really that bad?<p>I am someone just getting into Meteor Js and it seems like moving from MongoDB would make it Meteor trickier to learn.<p>Is it difficult to switch to an alternative? Thanks
评论 #11860225 未加载
wvenablealmost 9 years ago
I wonder how much data they are storing and in what pattern that they actually need a NoSQL database. I&#x27;m curious why someone would make that choice.
acarreraalmost 9 years ago
If you were inserting changes in the status you&#x27;d have much better data and never incur in such issues.
geoPointInSpacealmost 9 years ago
I&#x27;m prototyping in meteor using MongoDB and Compute Engine.<p>I have two VM instances in google cloud platform. One is a web app and the other is a MongoDB instance. They are in the same network. The connection I use is their internal IP.<p>Can other people eaves drop between my two instances?
apeacealmost 9 years ago
TL;DR During updates, Mongo moves a record from one position in the index to another position. It does this in-place without acquiring a lock. Thus during a read query, the index scan can miss the record being updated, even if the record matched the query before the update began.
评论 #11858674 未加载
oplessalmost 9 years ago
But it&#x27;s web scale! &lt;&#x2F;sarcasm&gt;
wizardhatalmost 9 years ago
TLDR: He was reading the database while another process was writing to it.<p>Why all the Mongo hate? I&#x27;m sure this would happen with other databases.
评论 #11858928 未加载
评论 #11859595 未加载
评论 #11860553 未加载
throoooowawayalmost 9 years ago
But is your database webscalwebscale? MongoDB is a web scale database.
评论 #11860892 未加载
rgoalmost 9 years ago
Everytime I hear arguments for going back to relational databases, I remember all the scalability problems I lived through for 15 years in relational hell before switching to Mongo.<p>The thing about relational databases is that they do everything for you. You just lay the schema out (with ancient E-R tools maybe) load your relational data, write the queries, indexes, that&#x27;s it.<p>The problem was scalability, or any tough performance situation really. That&#x27;s when you realized RDBMSs were huge lock-ins, in the sense that they would require an enormous amount of time to figure out how to optimize queries and db parameters so that they could do that magic outer join for you. I remember queries that would take 10x more time to finish just by changing the order of tables in a FROM. I recall spending days trying different Oracle hints just to see if that would make any difference. And the SQL-way, with PK constraints and things like triggers, just made matters worse by claiming the database was actually responsible for maintaining data consistency. SQL, with its naturalish language syntax, was designed so that businessman could inquire the database directly about their business, but somehow that became a programming interface, and finally things like ORMs where invented that actually translated code into English so that a query compiler could translate that back into code. Insane!<p>Mongo, like most NoSQL, forces you to denormalize and do data consistency in your code, moving data logic into solid models that are tested and versioned from day one. That&#x27;s the way it&#x27;s supposed to be done, it sorta screams take control over your data goddammit. So, yes, there&#x27;s a long way to go with Mongo or any generalistic NoSQL database really, but RDBMS seems a step back even if your data is purely relational.
评论 #11860385 未加载
评论 #11871453 未加载
评论 #11859655 未加载
评论 #11863076 未加载
TimPricealmost 9 years ago
The article is interesting, but title is fud. Besides, all this is not unexpected:<p>&gt; How does MongoDB ensure consistency?<p>&gt; Applications can optionally read from secondary replicas, where data is eventually consistent by default. Reads from secondaries can be useful in scenarios where it is acceptable for data to be slightly out of date, such as some reporting applications.<p><a href="https:&#x2F;&#x2F;www.mongodb.com&#x2F;faq" rel="nofollow">https:&#x2F;&#x2F;www.mongodb.com&#x2F;faq</a>
评论 #11858421 未加载