TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

MongoDB queries don’t always return all matching documents

444 点作者 dan_ahmadi将近 9 年前

44 条评论

im_down_w_otp将近 9 年前
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 未加载
lossolo将近 9 年前
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 未加载
hardwaresofton将近 9 年前
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 未加载
lath将近 9 年前
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 未加载
danbmil99将近 9 年前
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 未加载
ahachete将近 9 年前
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 未加载
cachemiss将近 9 年前
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 未加载
vegabook将近 9 年前
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 未加载
jsemrau将近 9 年前
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.
paradox95将近 9 年前
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 未加载
ruw1090将近 9 年前
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 未加载
twunde将近 9 年前
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.
wzy将近 9 年前
Does Meteor support a proper database system yet, a la. MySQL or Postgres?
评论 #11858311 未加载
aavotins将近 9 年前
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 未加载
jtchang将近 9 年前
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.
Animats将近 9 年前
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.
fiatjaf将近 9 年前
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 未加载
avital将近 9 年前
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 未加载
rjurney将近 9 年前
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.
shruubi将近 9 年前
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 未加载
d3ckard将近 9 年前
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.
hendzen将近 9 年前
Actually, if this lack of index update isolation is correct, you can get the matching document zero, one or <i>multiple times</i>!
doubleorseven将近 9 年前
Mongo, in one word: sucks. Couchbase, does not.
评论 #11857813 未加载
评论 #11858122 未加载
评论 #11858409 未加载
spullara将近 9 年前
It literally returns wrong answers for queries. I can&#x27;t believe anyone this thread is defending it.
jitix将近 9 年前
What storage engine are you using? I wonder if the same issue comes in wiredtiger MVCC engine.
评论 #11857908 未加载
alkonaut将近 9 年前
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...
xchaotic将近 9 年前
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.
Osiris将近 9 年前
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 未加载
clentaminator将近 9 年前
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>
partycoder将近 9 年前
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 未加载
tinix将近 9 年前
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>
bbcbasic将近 9 年前
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>
xenadu02将近 9 年前
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.
vs2370将近 9 年前
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
mouzogu将近 9 年前
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 未加载
wvenable将近 9 年前
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.
acarrera将近 9 年前
If you were inserting changes in the status you&#x27;d have much better data and never incur in such issues.
geoPointInSpace将近 9 年前
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?
apeace将近 9 年前
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 未加载
opless将近 9 年前
But it&#x27;s web scale! &lt;&#x2F;sarcasm&gt;
wizardhat将近 9 年前
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 未加载
throoooowaway将近 9 年前
But is your database webscalwebscale? MongoDB is a web scale database.
评论 #11860892 未加载
rgo将近 9 年前
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 未加载
TimPrice将近 9 年前
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 未加载