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. lucene随笔 IKAnalyzer StandardAnalyzer

    StandardAnalyzer 是单词分词器: String msg = "我喜欢你,我的祖国!china 中国,I love you!中华人民共和国"; 分词后的结果:[我], ...

  2. codeforces 788A Functions again

    …… 原题: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandia ...

  3. 【传输协议】TCP、IP协议族之数字签名与HTTPS详解

    文章转载出自:https://blog.51cto.com/11883699/2160032 安全的获取公钥 细心的人可能已经注意到了如果使用非对称加密算法,我们的客户端A,B需要一开始就持有公钥,要 ...

  4. 【git】一台机器上使用不同的git账号

    1.生成一个新的自定义名称的公钥: ssh-keygen -t rsa -C "shangxiaofei3@163.com" -f ~/.ssh/sxfself 一直点击回车 执行 ...

  5. 如何取消noarch.rpm包

    有一次部署zabbix服务器,不小心rpm -ivh zabbix的el7版本的rpm了,但是我的系统是centos6.5的,所以就尴尬了 rpm -ivh http://repo.zabbix.co ...

  6. Cassandra基础

    Apache Cassandra特性 Apache Cassandra由Facebook基于Amazon的Dynamo及其在Google的Bigtable上的数据模型设计开发的面相列的数据库,实现没有 ...

  7. SpringBoot2

    2018.3月Spring Boot2.0发布,是Spring Boot1.0发布4年之后第一次重大修订.Spring Boot2.0版本经历了 17 个月的开发,有 215 个不同的使用者提供了超过 ...

  8. IDEA 创建maven项目

    说明 创建Maven项目的方式:手工创建 好处:参考IntelliJ IDEA 14 创建maven项目二(此文章描述了用此方式创建Maven项目的好处)及idea14使用maven创建web工程(此 ...

  9. Learn ft=rom WTL: CXXImpl<T>

    // t9.cpp : Defines the entry point for the console application. // #include "stdafx.h" cl ...

  10. pri 知识点

    pri github:https://github.com/prijs/pri 添加路由后动态导入,使用的是 react-loadable:https://github.com/jamiebuilds ...