Probabilistic locking in SQLite
In SQLite, a reader/writer lock mechanism is required to control the multi-process concurrent access to a database. It is implemented using fcntl on Linux/Unix, and LockFileEx/UnlockFileEx on most Windows. But on Win95/98/ME the functions are not available. So on Win95/98/ME, SQLite uses probabilistic locking to simulate the reader/writer lock.
The idea is that using a exclusive locking pool to simulate a reader/writer lock.
- Acquire writer lock means locking all locks in the pool
- Acquire reader lock means locking a random lock in the pool
Writer lock is exclusive with both writer lock and reader lock. But multiple readers can access the lock at the same time, though there is some probability to conflict.
A conflict does not cause error, just makes the concurrent capacity a bit lower. The conflict probabilty depends on pool size and the concurrent process count.
In the latest SQLite, the pool size (SHARED_SIZE) is 510, according to the birthday attack formula, the 26th has more than 50% probabilistic to conflict.
Probabilistic locking in SQLite的更多相关文章
- Concurrent control in SQLite
This document describes the technologies to concurrent access to a SQLite database. There are also s ...
- SQLite的文件锁、并发与pager---(SQLite学习手册(锁和并发控制))
一.概述: 在SQLite中,锁和并发控制机制都是由pager_module模块负责处理的,如ACID(Atomic, Consistent, Isolated, and Durable).在含有数据 ...
- SQLite剖析之事务处理技术
前言 事务处理是DBMS中最关键的技术,对SQLite也一样,它涉及到并发控制,以及故障恢复等等.在数据库中使用事务可以保证数据的统一和完整性,同时也可以提高效率.假设需要在一张表内一次插入20个人的 ...
- About SQLite
About SQLite See Also... Features When to use SQLite Frequently Asked Questions Well-known Users Boo ...
- SQLite多线程读写实践及常见问题总结
多线程读写 SQLite实质上是将数据写入一个文件,通常情况下,在应用的包名下面都能找到xxx.db的文件,拥有root权限的手机,可以通过adb shell,看到data/data/packagen ...
- SQLite入门与分析(六)---再谈SQLite的锁
写在前面:SQLite封锁机制的实现需要底层文件系统的支持,不管是Linux,还是Windows,都提供了文件锁的机制,而这为SQLite提供了强大的支持.本节就来谈谈SQLite使用到的文件锁——主 ...
- Sqlite in Android
在Android上保存本地数据有三种方式,SharedPreferences.Files和Sqlite.SharedPreferences主要是用来保存键值对形式的程序配置信息,与ini.proper ...
- Architecture of SQLite
Introduction This document describes the architecture of the SQLite library. The information here is ...
- SQLite 线程安全和并发
SQLite 与线程 SQLite 是线程安全的. 线程模型 SQLite 支持如下三种线程模型 单线程模型 这种模型下,所有互斥锁都被禁用,同一时间只能由一个线程访问. 多线程模型 这种模型下,一个 ...
随机推荐
- ubuntu语言设置成汉语
打开设置system setting,进入语言支持,有语言和地区格式.下载须要的语言并应用到整个系统. 按说明来就可以 这样的方法使得部分英语变为汉语.
- C#获取当前活动窗口句柄
c# 获取当前活动窗口句柄,获取窗口大小及位置 2018年04月26日 13:48:21 漂泊_人生 阅读数:1889 需调用API函数 需在开头引入命名空间using System.Runtim ...
- python 【第一篇】初识python
人生苦短,我用python Python是我喜欢的语言,简洁.优美.容易使用.所以我总是很激昂的向朋友宣传Python的好处. python起源 1989年,为了打发圣诞节假期,Guido开始写Pyt ...
- 8148和8127中的ezsdk和dvrsdk
http://www.dajudeng.com/d2012081009b8a9d5de87101f69f31952c.html
- 【bzoj2003】[Hnoi2010]Matrix 矩阵
首先可以知道,如果已知第一行和第一列的数,那么可以很容易的计算出其余的数.进一步的,如果笔算将每个数的表达式写出可以得出如下结论: 第i行的第j个数(i>1,j>1)只与(1,1),(i, ...
- HNOI模拟 Day3.25 By Yqc
怕老婆 [问题描述] 有一天hzy9819,来到了一座大城市拥有了属于他自己的一双滑板鞋.但是他还是不满足想要拥有属于自己的一栋楼,他来到了一条宽敞的大道上,一个一个记录着这些楼的层数以方便自己选择. ...
- yispider 开源小说採集器 (来源http://git.oschina.net/yispider/yispider 我的改动版由于他的我无法跑)
我的git地址 http://git.oschina.net/yangdc/yispider 小说採集器 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/ ...
- [测试]单元测试框架NUnit
说到测试,相信大家都或多或少了解. 按照各自分类,就自己知道包括 A.单元测试.集成测试.系统测试 B.白盒测试.黑盒测试 C.压力测试.性能测试.安全测试 ...... 反正是太多太多.就做开发以来 ...
- ZOJ3965 Binary Tree Restoring
ZOJ3965 给定一颗二叉树的两种DFS序列 输出一种可能的二叉树的结构. 考察树的递归性质,不要想的太复杂. 当前节点在两个串中后面的节点假如不同则能确认两个子树,如果相同则把下个点作当前点的一个 ...
- 3-1 vue生存指南 - todolist实现-数据渲染
由于Vue.js作者是中国人,会说汉语,所以国内生态会更好一点.Vue.js作者是尤雨溪,