Databases Reference
In-Depth Information
Figure 2-1. GridFS breaks up large pieces of data and stores them in chunks.
Tip #19: Handle “seamless” failover
Often people have heard that MongoDB handles failover seamlessly and are surprised
when they start getting exceptions. MongoDB tries to recover from failures without
intervention, but handling certain errors is impossible for it to do automatically.
Suppose that you send a request to the server and you get back a network error. Now
your driver has a couple options.
If the driver can't reconnect to the database, then it obviously can't automatically retry
sending the request to that server. However, suppose you have another server that the
driver knows about, could it automatically send the request to that one? Well, it de-
pends on what the request was. If you were going to send a write to the primary, prob-
ably there is no other primary yet. If you were going to do a read, it could be something
like a long-running MapReduce to a slave that's now down, and the driver shouldn't
send that to some other random server (the primary?). So, it can't auto-retry to a dif-
ferent server.
If the error was a temporary network blip and the driver reconnects to the server im-
mediately, it still shouldn't try to send the request again. What if the driver sent the
original message and then encountered a network error, or errored out on the database
response? Then the request might already be being processed by the database, so you
wouldn't want to send it a second time.
 
Search WWH ::




Custom Search