Customizing RavenDB: A simple RavenDB server bundle for replication conflict handling

This version of Customizing Ravendb Simple Ravendb Server Bundle Replication Conflict Handling Flna393988 - Breaking News | NBC News Clone was adapted by NBC News Clone to help readers digest key facts more efficiently.

Last week in our webinar on RavenDB, we mentioned that we have at least two RavenDB instances in each of our data centers and that we have each of them configured to replicate to all the others. One attendee asked how we handle replication conflicts.

First, we try to limit replication conflicts, by having all writes to a given database directed at a single RavenDB instance. We showed off our UI for managing that, and I have another post in the works describing the details.

But there are inevitably cases where there is a conflict. We have some automated processes that update content, so multiple saves in rapid succession are not unusual. We also have integration challenges with other systems, resulting in our receiving the same document multiple times at more or less the exact same moment. If our write master changes at an inopportune moment (either due to failover or an intentional change by an admin), we'll likely have a replication conflict.

As I mentioned in my post on read-only vs. read-write databases, our front end web apps aren't allowed to write to most databases, so they can't resolve the conflict. In any case, that would probably make things worse, given the number of front-end servers we have.

Fortunately, there's an easy solution for us. The nature of our data and our business means we always want the latest version of a document to win. The Replication bundle provides a hook to allow custom handling of replication conflicts on the RavenDB server. We simply compare the Last-Modified value of the existing document with that of the inbound replicating document. Whichever has the later date wins.

Here's the code for the LastInWinsReplicationConflictResolver: https://gist.github.com/2012016

Score another one for the simple extensibility provided by RavenDB.

×
AdBlock Detected!
Please disable it to support our content.

Related Articles

Donald Trump Presidency Updates - Politics and Government | NBC News Clone | Inflation Rates 2025 Analysis - Business and Economy | NBC News Clone | Latest Vaccine Developments - Health and Medicine | NBC News Clone | Ukraine Russia Conflict Updates - World News | NBC News Clone | Openai Chatgpt News - Technology and Innovation | NBC News Clone | 2024 Paris Games Highlights - Sports and Recreation | NBC News Clone | Extreme Weather Events - Weather and Climate | NBC News Clone | Hollywood Updates - Entertainment and Celebrity | NBC News Clone | Government Transparency - Investigations and Analysis | NBC News Clone | Community Stories - Local News and Communities | NBC News Clone