DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Eclipse JNoSQL 1.0.2: Empowering Java With NoSQL Database Flexibility
  • The Power of NoSQL Databases: Exploring Polyglot Persistence [Video]
  • Understanding RDS Costs
  • NULL in Oracle

Trending

  • Auto-Scaling DynamoDB Streams Applications on Kubernetes
  • Docker and Kubernetes Transforming Modern Deployment
  • Scalable Rate Limiting in Java With Code Examples: Managing Multiple Instances
  • Modern Data Backup Strategies for Safeguarding Your Information
  1. DZone
  2. Data Engineering
  3. Databases
  4. Enhancing the RavenDB consistency model

Enhancing the RavenDB consistency model

Oren Eini user avatar by
Oren Eini
·
Jun. 22, 11 · News
Like (0)
Save
Tweet
Share
4.79K Views

Join the DZone community and get the full member experience.

Join For Free

from the get go, we have built ravendb to be as easy to use as possible. quite explicitly, wherever possible, we aimed to make it as simple as possible for someone familiar with .net. the fun part is sometimes looking at people’s expectations and answering them is a pleasure, such as this one:

image

the reasons for this exchange being amusing is that ravendb doesn’t have the concept of expensive queries. for the most parts, queries are merely scanning through an already computed index. ravendb does no computation and very little work to answer your queries, so the notion of an expensive query is meaningless, there aren’t any.

that said, this behavior does comes at a cost, it means that we have to do the work of computing the indexes at some stage, and in our case, we have chosen to do so on the background. what that means, in turn, is the whole notion of queries potentially returning stale results. as it turned out, there is a actually a surprisingly few cases where you can’t tolerate some staleness in your application, and that makes ravendb highly suited for a large number of scenarios.

there is, however, one common scenario that is annoying, the create –> list flow. as a user, i want to complete the create screen:

image

and then i want to see the list screen:

image

and naturally i expect to see the just created item in the list. that is the one scenario where people usually run into ravendb’s consistency model, and it brought a few complaints every now and then. if the timing is just wrong, you may be able to issue the next request before the addition to the database had the chance to index, resulting in a missing update.

usually, the advice was to add a waitfornonstaleresultsasofnow(), which resolved this issue, so we didn’t really consider this any further. it was just one of those things that you had to understand about the way ravendb worked.

recently, however, we got a bug report for this exact scenario, and the user couldn’t just use waitfornonstaleresultsasofnow(), or to be rather more accurate, he was already using it, but it wasn’t working. we eventually figured out that the problem was clock synchronization between the server and client computers. that forced us to re-consider how to approach this. after looking at several alternatives, we ended up creating a new consistency model for ravendb.

in this consistency model, we are basically ensuring a very simple metric, “you can query anything that you have written”, instead of relying on the time being the same everywhere, we have decided to use the etags that are being reported back to the server. using this approach, you can basically ignore the difference between ravendb and the traditional relational database, since it will behave (externally), in much the same fashion.

you can enable this mode on a per query basis:

image

or you can enable this for all queries:

image

i am pretty proud of this feature, since it simplify a lot for most users, and it provides a very effective (and simple) way to approach consistency. this is especially true if we are talking about multiple clients working on the same database (which is the case in the issue that was raised).

whenever each client is writing, they will have to wait for their changes to be indexed, but they won’t have to wait for the changes from any other client. that matches the user’s expectation, and also allow ravendb to answer most queries without doing any waiting whatsoever.

Consistency model Relational database

Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Eclipse JNoSQL 1.0.2: Empowering Java With NoSQL Database Flexibility
  • The Power of NoSQL Databases: Exploring Polyglot Persistence [Video]
  • Understanding RDS Costs
  • NULL in Oracle

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: