小贝壳爸爸

天桥扛把子


  • 首页

  • 分类

  • 关于

  • 归档

  • 标签

需要跟踪的crdb txn细节列表

发表于 2017-12-18 | 分类于 cockroachdb

txn实现细节

  1. txnwait.Queue
  2. TimestampCache
  3. CommandQueue
  4. quiescer
  5. txn heartbeat
  6. txn restart
  7. txn epoch
阅读全文 »

crdb事务处理流程

发表于 2017-12-14 | 分类于 cockroachdb

session.txnState初始化

如果当前session不在事务中,则reset session的txnState

pkg/sql/executor.go

1
2
3
4
5
6
7
txnState.resetForNewSQLTxn(
e, session,
autoCommit, /* implicitTxn */
false, /* retryIntent */
e.cfg.Clock.PhysicalTime(), /* sqlTimestamp */
session.DefaultIsolationLevel,
roachpb.NormalUserPriority,
阅读全文 »

golang underscore下划线作用

发表于 2017-12-13 | 分类于 go

Import

1
2
3
4
5
import (
_ "github.com/cockroachdb/cockroach/pkg/ccl" // ccl init hooks
"github.com/cockroachdb/cockroach/pkg/cli"
_ "github.com/cockroachdb/cockroach/pkg/ui/distccl" // ccl web UI init hook
)

当前文件不使用import的相关函数,但是需要先执行其中的init function。

阅读全文 »

crdb HLC 实现

发表于 2017-12-13 | 分类于 cockroachdb

HLC

HLC是Hybrid Logical Clock的缩写,混合逻辑时钟。时钟分为物理时钟和逻辑时钟。

物理时钟: 电子设备,计算有固定频率晶体的震荡次数,存在时钟偏移和时钟漂移,会导致时钟不连续的变化,比如时间回退等, 以及长时间使用导致时钟存在偏差,普通石英晶体时钟漂移率在(10)-6s/s, 即每1 000 000s会导致1s的偏差。 原子钟的偏倚率在(10)-13.

逻辑时钟: 时间发生的逻辑顺序,可以是顺序的序号,和物理时间相对。

HLC同时使用了物理时钟和逻辑时钟,能够保证单点的时间发生器是单调递增的,同时能够尽量控制不同节点之间的时钟偏差在规定的误差范围内。主要用于分布式系统中。

阅读全文 »

Raft library使用

发表于 2017-12-12 | 分类于 raft

Raft library介绍

Raft library是etcd中的raft实现,只实现了Raft算法,使用者需要自己提供transportation层用于节点间通信,storage层用于持久化Raft log和state.

Raft library实现如下特性:

  • Leader election
  • Log replication
  • Log compaction
  • Membership changes
  • Leadership transfer extension

使用Raft library的项目:

  • etcd
  • tikv
  • cockroachdb
  • dgraph
阅读全文 »

A Critique of ANSI SQL Isolation Levels

发表于 2017-11-30 | 分类于 paper

事务隔离级别定义

操作冲突: 两个不同事务对同一个数据项进行操作,且至少一个为write操作,则这两个操作是冲突操作。

等价调度: 不存在冲突的操作可以进行执行顺序的交换,交换后的结果与交换前效果是一致的,称为等价调度。

可串行化: 并发执行的事务操作顺序,通过等价调度,可以得到与顺序执行相同的调度,则称为事务是可串行化的。

隔离级别对应的3个现象:

  1. Dirty Read

Transaction T1 modifies a data item. Another transaction T2 then reads that data item before T1 performs a COMMIT or ROLLBACK. If T1 then performs a ROLLBACK, T2 has read a data item that was never committed and so never really existed.

  1. Non-repeatable or Fuzzy Read

Transaction T1 reads a data item. Another transaction T2 then modifies or deletes that data item and commits. If T1 then attempts to reread the data item, it receives a modified value or discovers that the data item has been deleted.

  1. Phantom

Transaction T1 reads a set of data items satisfying some

. Transaction T2 then creates data items that satisfy T1’s and commits. If T1 then repeats its read with the same , it gets a set of data items different from the first read.

对应的宽泛解释和实际解释:

1
2
3
4
5
6
P1: w1[x]...r2[x]...((c1 or a1) and (c2 or a2) in any order)
A1: w1[x]...r2[x]...(a1 and c2 in any order)
P2: r1[x]...w2[x]...((c1 or a1) and (c2 or a2) in any order)
A2: r1[x]...w2[x]...c2...r1[x]...c1
P3: r1[P]...w2[y in P]...((c1 or a1) and (c2 or a2) any order)
A3: r1[P]...w2[y in P]...c2...r1[P]...c1

隔离级别和现象的对应关系:

ANSI SQL Isolation Levels Defined in terms of the Three Original Phenomena

串行化的定义前面已经讲过了,排出P1,P2,P3三种现象并不是串行化的实际定义。

crdb insert流程

发表于 2017-11-27 | 分类于 cockroachdb

语句

1
2
3
4
5
6
7
8
9
create database test;
use test;
create table t1(c1 int primary key, c2 varchar(20));
begin;
insert into t1 values(2, 'aaaaaaa');
阅读全文 »

docker使用

发表于 2017-11-22 | 分类于 docker

image相关操作

搜寻image

1
2
3
4
5
6
7
8
➜ docker search --limit 10 cockroachdb/builder
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
cockroachdb/cockroach CockroachDB is an open source, survivable,... 39
electronuserland/electron-builder electron-builder 14 [OK]
deis/builder Docker-in-docker image builder for the Dei... 5
jekyll/builder Builder image 2 [OK]
abcstartsiden/builder Images for builder 1
cockroachdb/builder Image containing tools for building cockroach 1
阅读全文 »

crdb session变量维护堆栈

发表于 2017-11-15 | 分类于 cockroachdb

session默认事务隔离级别

pkg/storage/engine/enginepb/mvcc3.pb.go

1
2
3
4
5
6
7
8
9
10
11
type IsolationType int32
const (
SERIALIZABLE IsolationType = 0
SNAPSHOT IsolationType = 1
)
var IsolationType_name = map[int32]string{
0: "SERIALIZABLE",
1: "SNAPSHOT",
}
阅读全文 »

crdb代码sql到kv调用堆栈

发表于 2017-11-15 | 分类于 cockroachdb

跟踪insert和select语句对应的从sql层到kv层的调度堆栈

阅读全文 »
1234…8
Louis

Louis

记录工作和生活点滴

75 日志
22 分类
108 标签
GitHub
© 2018 true
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.3