Hard commits are about durability, soft commits are about visibility

 Transaction Logs

首先介绍下solrcloud的index流程。

1)update请求发送给任意节点(NodeA)。

2)若该节点不是leader,将请求转发给leader。

3)leader将请求转发给所有副本节点(同一分片)。

后面就是执行结果的响应(response),所有副本节点反馈给leader,leader再反馈给原接收到请求的节点(NodeA)。

当所有leader都反馈给NodeA(执行update完毕),NodeA再反馈给“客户端”。在这时候,所有的更新操作被刷到tlog中。

如果JVM挂了,这些操作任然会被写入磁盘,如果操作系统挂了,就会丢掉这些操作日志。

如果JVM重启,那么solr会从tlog中进行数据恢复。

注意:

1)hard commit时产生一个新的tlog文件,如果被关闭的tlog中包含的documents超过100,则会删除最老的一个tlog文件。

e.g.

So consider if you are indexing in batches of 25 documents and hard committing after each one (not that you should commit that often, but just saying). You should have 5 tlogs at any given time. the oldest four (closed) contain 25 documents each, totaling 100 plus the current tlog file. When the current tlog is closed, the oldest tlog will be deleted, and a new one opened.

2)如果一直没有hard commit,那么这个tlog文件可能会很大(一直没有close)。当solr重启的时候可能会造成较大的性能消耗。

Soft commit

Soft commit让searcher对更新可见,但是会导致“top level caches”失效(filterCache、queryResultCache等),包括FieldValueCache失效,那么facet请求需要等待cache完成刷新。

如果频繁的soft commit会导致“top level caches”很少被命中,导致性能问题。

不过“segment level caches”并不会失效,例如function queries、sorting caches等。

Soft commit到底做了些什么?

1)tlog会持续被写入,并不会重新创建。

2)searcher对更新可见。

3)一些cache会被重新加载(top level caches)

虽然soft commit比hard commit更轻量,但是TANSTAAFL,There Ain't No Such Thing As A Free Lunch. Soft commit支持nrt,不过也需要额外的开销,这取决于你系统对nrt的忍耐度。

Hard commit

Hard commit到底做了什么?

1)创建新的tlog,如果超过100个documtns,那么就会删除老的tlog文件。

2)创建新的segment,并flush到磁盘。

3)segment合并有可能会被触发。

Hard commit还有一个选项:openSearcher。

openSearcher=true

Searchers会被重新打开,并且所有caches会失效,执行自动预热。只有这样才能对更新可见。

openSearcher=false

更新不可见。

简单的总结:

SoftCommit:更新可见,缓存失效,不会写入磁盘,追加tlog。

HardCommit:更新不可见,写入磁盘,新建tlog。

https://lucidworks.com/blog/understanding-transaction-logs-softcommit-and-commit-in-sorlcloud/

Hard commits, soft commits and transaction logs的更多相关文章

  1. mkdir: cannot create directory ‘/soft/hadoop-2.7.3/logs’: Permission denied问题

    启动hadoop时,报错“mkdir: cannot create directory ‘/soft/hadoop-2.7.3/logs’: Permission denied” 注:/soft/ha ...

  2. Solr Cloud - SolrCloud

    关于 Solr Cloud Zookeeper 入门,介绍 原理 原封不动转自 http://wiki.apache.org/solr/SolrCloud/ ,文章的内存有些过时,但是了解原理. Th ...

  3. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

  4. Microsoft SQL Server Trace Flags

    Complete list of Microsoft SQL Server trace flags (585 trace flags) REMEMBER: Be extremely careful w ...

  5. What is SolrCloud? (And how does it compare to master-slave?)

    What is SolrCloud? (And how does it compare to master-slave?) SolrCloud is a set of new features and ...

  6. Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler--转载

    原文地址:https://gist.github.com/maxivak/3e3ee1fca32f3949f052 Install Solr download and install Solr fro ...

  7. Solr基础知识二(导入数据)

    上一篇讲述了solr的安装启动过程,这一篇讲述如何导入数据到solr里. 一.准备数据 1.1 学生相关表 创建学生表.学生专业关联表.专业表.学生行业关联表.行业表.基础信息表,并创建一条小白的信息 ...

  8. PHP7函数大全(4553个函数)

    转载来自: http://www.infocool.net/kb/PHP/201607/168683.html a 函数 说明 abs 绝对值 acos 反余弦 acosh 反双曲余弦 addcsla ...

  9. The Myths about Transactions (ACID) and NoSQL

    There has been widespread characterization of one of the major distinctions between NoSQL and tradit ...

随机推荐

  1. RNN-LSTM-GRU-BIRNN

    https://blog.csdn.net/wangyangzhizhou/article/details/76651116 共三篇 RNN的模型展开后多个时刻隐层互相连接,而所有循环神经网络都有一个 ...

  2. innerHTML与innerText功能的强大

    例: <div id="study"> <span style="color:red">学习</span>study < ...

  3. C语言---辗转相除法 HDU 2503

    Problem Description 给你2个分数,求他们的和,并要求和为最简形式. Input 输入首先包含一个正整数T(T < =1000),表示有T组测试数据,然后是T行数据,每行包含四 ...

  4. django CBV和FBV写法总结

    一.FBV function base views 平常我们的写法,一个URL对应一个视图函数 二.CBV 1.url 配置 path('test/',views.CBVTest.as_views() ...

  5. LG5056 【模板】插头dp

    题意 题目背景 ural 1519 陈丹琦<基于连通性状态压缩的动态规划问题>中的例题 题目描述 给出n*m的方格,有些格子不能铺线,其它格子必须铺,形成一个闭合回路.问有多少种铺法? 输 ...

  6. maven(一)

    Maven的简介 什么是maven 是apache下的一个开源项目,是纯java开发,并且只是用来管理java项目的 Maven好处 普通的传统项目 maven项目 分析:maven项目为什么这么小? ...

  7. 这样学习C语言最有效(高级技巧)——共勉

    第一章 学习C语言的起跑线 1.1 C语言已死? 本资料描述的是使用C语言的高级技巧,力求将你的C语言能力由"基础"提升为"高级".但是学习态度胜过学习方法,在 ...

  8. Cassandra -- Cassandra 3.0版本安装

    ============================================================ 服务器信息 搭建三节点的Cassandra群集: SERVER1: 192.1 ...

  9. C# Winform 怎么让按钮在Panel里居中显示

    把pannel里面的多个按钮的那个anchor属性全部去掉,如下图: 再用VS2010自带的工具调一下即可: 小注: 有的时候我们却想子控件在父控件里的相对位置不要随着父控件的变大缩小而变化,或者控件 ...

  10. react-router v4.0 知识点

    react-router 提供了一个withRouter组件 withRouter可以包装任何自定义组件,将react-router 的 history,location,match 三个对象传入. ...