Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

50 suggestions for MongoDB developers Tip20

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This series of articles are translated from "50 Tips and Tricks for MongoDB Developers". I can't find the Chinese version for the time being. Anyway, I have been studying mongodb deeply recently, so I just want to translate it. On the one hand, enhance the effect of our own learning, on the other hand, let the big family to experience what we mongodb users need to pay attention to.

First of all, I declare that my English level is not too high, and some English translation into Chinese can not find suitable words to express, so the original English words may appear in the article, or the translation in some places will be a little blunt, that is to say, there will be literal translation. The main purpose of translating this book is for everyone to learn and explore. If there is any inaccuracy in translation, or if there is a more accurate translation, please point out that I will correct it in time. Thank you in advance.

Tip#20.Handle replica set failure and failover

Handle the failure and recovery of replication sets

Your application should be able to handle all possible failures encountered in a replication set.

Suppose your application throws a "master not found" error. There are two possible causes of this error. Your replica set may be undergoing failure recovery to restore a new primary, and you must gracefully deal with the time it takes to make a primary selection. This period will last for a few seconds, or if you are unlucky, it could be 30 seconds or more. If you are on the other side of the network partition, you may not see master for hours.

Not finding master is a serious problem, and if such a request occurs, whether your application can accept read-only mode. Your application should be able to handle both short-term and long-term read-only.

Whether or not master exists, you should continue to provide reading services.

During the primary election phase, server members go through a brief unreadable, recovery phase. During this period, if the driver reads the data, the member will throw an exception and cannot find master and slave.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report