﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>AJ,
Let us assume that you have just crashed in the middle of step 2.
But, let us assume that you have more than a single server running.
That means that you can't just "get list of pending tx, or applied tx", because there are other processes that are going to be actually processing it.

What it goes down to is that because MongoDB doesn't have transactions, you have to build your own distributed transaction coordinator with the basic blocks of atomic swap.
I am sorry, but I see no point in which it make sense to do something like that for real software. 
I am willing to bet that most people's attempt to write a transaction manager are going to be riddled with holes for a variety of edge cases, and that is even before we include the fast that they actually recommend adding business logic to the transaction handler part.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment40</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment40</guid><pubDate>Fri, 24 Jun 2011 22:19:57 GMT</pubDate></item><item><title>AJ commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>The documentation says 'These "repair" jobs should be run at application startup and possibly at regular interval to catch any unfinished transaction.'

1. any failure between after step 1 and before step 3: Application should get a list of transactions in state "pending" and resume from step 2.
2. any failure after step 3 and before step 5: Application should get a list of transactions in state "applied" and resume from step 4.

Repair jobs will repair if something is in failed state. If not, no action is taken by that repair step.
I will expand on it later.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment39</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment39</guid><pubDate>Fri, 24 Jun 2011 21:43:19 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>AJ,
who is going to restart this step? Where is the transaction coordinator? Where is the information about the tx itself is stored?</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment38</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment38</guid><pubDate>Fri, 24 Jun 2011 21:18:10 GMT</pubDate></item><item><title>AJ commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Step 2 is idempotent. A failure of it midway can be simply restarted. It only pushes if not already pushed. So a repeat of step 2 will not harm (by duplication).

All the steps are either atomic or idempotent. Crash is handled either through restart or rollback at each step (detailed in the documentation).
Sure it is not pretty or easy. But for rare transactional need on a non-transactional database, one can give it a serious thought.

I am not comparing to RavenDB (or other RDBMS) true transactional feature. Just that it was not tried out well enough in MongoDB by your client.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment37</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment37</guid><pubDate>Fri, 24 Jun 2011 17:14:37 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>AJ,
You are kidding, right?
This still doesn't solve the problem of crashing midway, consider the case of a failure in the middle of step 2.

More to the point, this is a LOT of code, it is VERY complicated, it has *tons* of failure scenarios, hard to detect bugs, etc.

Sorry, the fact that you can hop on one leg from New York to Las Vegas doesn't imply that this is a viable means of transportation.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment36</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment36</guid><pubDate>Fri, 24 Jun 2011 16:55:47 GMT</pubDate></item><item><title>AJ commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Refer to http://www.mongodb.org/display/DOCS/two-phase+commit for 10gen's suggested way to handle multi-doc transaction with MongoDB.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment35</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment35</guid><pubDate>Fri, 24 Jun 2011 13:56:49 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Marcel,
Yes, this has been implemented for production
To be fair, it is a stopgap measure while they were researching a better alternative</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment34</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment34</guid><pubDate>Wed, 22 Jun 2011 06:57:44 GMT</pubDate></item><item><title>Marcel Konnegen commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Hi Ayende,
I usually don't post very often, but this time, I must say that I am absolutely shocked by how any serious software developer could produce such a "horse excrement" (as you mentioned) in a productive environment. Has the above code really been implemented in a productive environment???</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment33</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment33</guid><pubDate>Wed, 22 Jun 2011 06:42:11 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Chris,
Well, yes, but while it is also possible to walk from Los Angeles to Chicago, you don't see people do that very often.
In fact, by most people perception, "you can't walk from Los Angeles to Chicago" is a true statement.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment32</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment32</guid><pubDate>Tue, 21 Jun 2011 16:00:49 GMT</pubDate></item><item><title>Chris Wright commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>You can definitely write transaction support on top of a non-transactional data store. It just takes far too much time to be useful for most people whose product is not a transactional data store.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment31</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment31</guid><pubDate>Tue, 21 Jun 2011 15:56:34 GMT</pubDate></item><item><title>Neil commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Thanks Ayende. Makes sense really, choose your db based on your essential requirements.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment30</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment30</guid><pubDate>Tue, 21 Jun 2011 11:13:10 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Neil,
I am not. You can't simulate transactions if the db doesn't support it.
Then, you are left with either:
- Avoid requiring transactions (which can be hard, but is possible)
- Choose a db that supports them
</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment29</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment29</guid><pubDate>Tue, 21 Jun 2011 10:50:36 GMT</pubDate></item><item><title>Neil commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Ayende, 
Understood that it's a simplification of the real problem. As you say, the original snippet is ugly and brittle and I agree that trying to approximate transactions is a not an ideal solution. How then, would you propose working around the issue if changing the entire persistence mechanism is not a justifiable option?</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment28</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment28</guid><pubDate>Tue, 21 Jun 2011 10:48:38 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Daneil,
Take a look at RaccoonBlog sample app (which is also powering this blog), this is an example of what I consider to be well designed RavenDB application.
The basic idea is that you don't really need to worry about session life cycle and calling save changes in the controller.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment27</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment27</guid><pubDate>Tue, 21 Jun 2011 08:18:45 GMT</pubDate></item><item><title>Daniel Lang commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Ayende,

I get the point that Raven ist probably the best document-db, but what do you mean with "This isn’t the best RavenDB code, ideally I wouldn’t have to create the session here"? I would like to know, how I could write the same code even better / shorter?

Many thanks in advance!</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment26</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment26</guid><pubDate>Tue, 21 Jun 2011 07:38:13 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Neil,
The example is intentionally over simplified, to make a point.
Yes, there are better ways of doing that, as for "not truly transactional", that is a scary concept.
Having transactions is like being pregnant, you can't be half &amp; half.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment25</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment25</guid><pubDate>Tue, 21 Jun 2011 07:28:25 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Demis,
You are correct that there are some other NoSQL dbs out there that offer transactions, but most often, one of the laments against NoSQL is that there are no transactions</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment24</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment24</guid><pubDate>Tue, 21 Jun 2011 07:26:59 GMT</pubDate></item><item><title>meisinger commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>@Neil +1
I was thinking the same exact thing... why not "event source" it and be done?
And while it is not in a nice "transaction" it could still be err... transactional. It almost sounds like they were trying to get a "consistent read" out of it...</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment23</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment23</guid><pubDate>Tue, 21 Jun 2011 03:51:03 GMT</pubDate></item><item><title>Neil commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>I'm not particularly well versed in either NoSQL or DDD/CQRS but would this scenario be a candidate for event sourcing? 

It seems as if storing a PostAdded document could offload the state management and transactional logic to some other process. If interrupted, said process could simply pick up where it left off. Not truly transactional I know, but could remove some of the issues with original code snippet.
</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment22</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment22</guid><pubDate>Tue, 21 Jun 2011 03:31:24 GMT</pubDate></item><item><title>Demis Bellot commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>“We tried using NoSQL, but we are moving to Relational Databases because they are easier…”

I think this article should probably make mention that there are other NoSQL databases that support transactions since it's a little misleading as-is:

http://nosql.mypopescu.com/post/6732339201/multi-document-transactions-in-ravendb-vs-other-nosql

In the NoSQL space, there are a couple of other solutions that support transactions:

  - Google Megastore
  - Redis has two mechanisms that come close to transactions: MULTI/EXEC/DISCARD and pipelining 
      —this one is exemplified in this Redis based triplestore database implementation
  - many of the graph databases (Neo4j, HyperGraphDB, InfoGrid)
</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment21</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment21</guid><pubDate>Tue, 21 Jun 2011 01:51:18 GMT</pubDate></item><item><title>SSII Lyon commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>&lt;&lt;we are moving to Relational Databases because they are easier&gt;&gt;
Doesn't that simply come from the fact that 99.9% of everything taught in school and in books is on the relational model? Of course if the skillset and mindset of IT people are formatted to be relational, relational is going to seem easier.

Does anyone know of a good primer on document DBs that could help alleviate this?</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment20</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment20</guid><pubDate>Mon, 20 Jun 2011 22:29:33 GMT</pubDate></item><item><title>jimmy zimmerman commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>&gt;but at this point I think that I am busy explaining why horse excrement isn’t suitable for gourmet food

Greatest. Comment. Ever. +D</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment19</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment19</guid><pubDate>Mon, 20 Jun 2011 19:20:05 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Peter,
That really depend, usually we are talking about document model in aggregates, but there are a lot of associations between those aggregates.
In most scenarios, you probably are wrong to require mutli docs transactions, because it is okay to do this without multi doc transactions in most cases. Most of the time it is an indication of bad aggregates boundaries, but there are good reasons to want to have multiple documents (for example, different reasons for updating something in the same aggregate means that this is split to two documents) that you then need to modify in tandem.
This is usually the case of practical reasons causing the splitting of a single aggregate.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment18</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment18</guid><pubDate>Mon, 20 Jun 2011 18:22:51 GMT</pubDate></item><item><title>Peter commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Ayende, 
Thanks for the response. I was genuinely curious, not trying to score a point on either side. I think you're right on and in practice it is much better to support multi-doc transactions in those scenarios. From a purely theoretical modeling standpoint, do you think it's fair to say that if you are using a document database and have a lot of mult doc transactions, that's probably a warning sign?</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment17</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment17</guid><pubDate>Mon, 20 Jun 2011 17:54:36 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Peter,

* RavenDB has the notion of locality, so even when you have multiple servers, you can still keep related data local, so you can get multi doc transactions.
* In multiple servers, you still have DTC, it isn't recommended, yes. But it might be suitable for rare cases.

Note that RavenDB allows you to grow from a single server (itself able to serve a lot of data) to multiple servers. That growth means changes to your application, certainly. But I think that it is better than saying "this feature is hard to implement using shards, we won't allow it ever"</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment16</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment16</guid><pubDate>Mon, 20 Jun 2011 17:14:10 GMT</pubDate></item><item><title>Peter commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>So the general idea here is MongoDB does not support multiple document transactions, RavenDB does. However, as you mention, if you have to shard and don't/can't localize your documents, you have to use distributed transactions, which you seem to recommend against.

If somebody reached that point with RavenDB, many shards, non local documents, what would you recommend? You'd have to change the model right? Or if possible just use map-reduces for counts and the like.

In other words, if your data gets big enough, you'll probably run against this issue anyway, Mongo or Raven?
</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment15</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment15</guid><pubDate>Mon, 20 Jun 2011 17:05:56 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Mike,
Thanks, minor detail, but I fixed it.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment14</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment14</guid><pubDate>Mon, 20 Jun 2011 16:35:39 GMT</pubDate></item><item><title>Mike McG commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>You forgot to pass 'userId' into 'session.Load&lt;User&gt;()'.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment13</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment13</guid><pubDate>Mon, 20 Jun 2011 15:05:28 GMT</pubDate></item><item><title>Ayende Rahien commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Ajai,
As I said, that is really an issue of how you want to deal with things.
In their scenario, it absolutely made sense to have it happen in this fashion. The blog model is a very simple one, and one that is very easy to work with and explain, but it is not something that you can say: "NEVER lose this data".
The actual information scenario did require them to have all or nothing semantics, please do not try to read too much into the sample scenario, it is intentionally simplified to make it easy to understand.</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment12</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment12</guid><pubDate>Mon, 20 Jun 2011 13:24:39 GMT</pubDate></item><item><title>Ajai commented on You&amp;rsquo;ll pry transactions from my dead, cold, broken hands</title><description>Nice, that comment that I spent half hour typing out was rolled back because some stupid counts could not be updated :)

I'd blame your client here, load and save User, Post to update some count?? Mongo $inc anyone?

And by the way was surprised to read Mongo has a global reader writer lock across collections! Choose wisely, but guess if it's good enough for Foursquare it is good enough for rest of us....

Ajai</description><link>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment11</link><guid>http://ayende.com/23553/you-ll-pry-transactions-from-my-dead-cold-broken-hands#comment11</guid><pubDate>Mon, 20 Jun 2011 13:19:17 GMT</pubDate></item></channel></rss>