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 支持如下三种线程模型 单线程模型 这种模型下,所有互斥锁都被禁用,同一时间只能由一个线程访问. 多线程模型 这种模型下,一个 ...
随机推荐
- 怎样把UCos-ii_在STM32上的移植
下载代码 stm32 标准外设库是 stm32 全系列芯片的外设驱动,有了它能够大大加速我们 开发 stm32. 首先从 st 公司的站点下载最新的 stm32 标准外设库,写本文时最新的版本号是 V ...
- Python学习系列之异常处理
什么是异常处理 python内置了一套try···except···finally的错误处理机制 当程序出错的时候进行捕捉,然后根据捕捉到的错误信息进行响相应的处理 常用的内建异常 初识异常处理 如例 ...
- Redis学习笔记3-Redis5个可运行程序命令的使用
在redis安装文章中,说到安装好redis后,在/usr/local/bin下有5个关于redis的可运行程序.以下关于这5个可运行程序命令的具体说明. redis-server Redisserv ...
- android的toogleButton和switch的使用方法
这两个是button开关.监听CheckedChangeListener toggle_layout.xml: <? xml version="1.0" encoding=& ...
- union关键字及大小端模式
1. union 关键字 union 维护足够的空间来置放多个数据成员中的“一种”,而不是为每一个数据成员配置空间,在 union 中所有的数据成员共用一个空间,同一时间只能储存其中一个数据成员,所有 ...
- hbase 增删改查 api 简单操作
package com.utils; import java.io.IOException; import java.util.ArrayList; import java.util.List; im ...
- Oracle高水位线
Oracle高水位线 https://blog.csdn.net/jx_jy/article/details/50607790 Oracle高水位线的概念 Oracle里面的对象放到存储级别都称为se ...
- 05_锅炉压力案例_java实现
最开始是有机顶盒,后来电视里面都带着一个安卓的设备.现在空调.冰箱.洗衣机都跃跃欲试地想把这个东西加上.海尔出了一款智能冰箱,就是在冰箱门上嵌了一个12寸的屏幕.这个屏幕实际上就是一个安卓的平板似的. ...
- 10.17NOIP模拟赛
#include<iostream> #include<cstdio> #include<cstring> #define N 1001 using namespa ...
- 阿里云短信验证_基于阿里云OpenAPI实现
阿里云短信服务 背景简介: 短信验证以及短信通知,目前已经应用的非常广泛,最近因项目需要,需要将原来的短信接口换成阿里云的的短信服务,原项目集成的短信服务能够实现短信的发送以及短信的验证整个过程,简单 ...