小贝壳爸爸

天桥扛把子


  • 首页

  • 分类

  • 关于

  • 归档

  • 标签

crdb代码阅读02——system数据库初始化流程

发表于 2018-04-16 | 分类于 cockroachdb

表描述定义

pkg/sql/sqlbase/system.go

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
UsersTable = TableDescriptor{
Name: "users",
ID: keys.UsersTableID,
ParentID: keys.SystemDatabaseID,
Version: 1,
Columns: []ColumnDescriptor{
{Name: "username", ID: 1, Type: colTypeString},
{Name: "hashedPassword", ID: 2, Type: colTypeBytes, Nullable: true},
},
NextColumnID: 3,
Families: []ColumnFamilyDescriptor{
{Name: "primary", ID: 0, ColumnNames: []string{"username"}, ColumnIDs: singleID1},
{Name: "fam_2_hashedPassword", ID: 2, ColumnNames: []string{"hashedPassword"}, ColumnIDs: []ColumnID{2}, DefaultColumnID: 2},
},
PrimaryIndex: pk("username"),
NextFamilyID: 3,
NextIndexID: 2,
Privileges: NewCustomRootPrivilegeDescriptor(SystemAllowedPrivileges[keys.UsersTableID]),
FormatVersion: InterleavedFormatVersion,
NextMutationID: 1,
}
阅读全文 »

crdb代码阅读01——cmux多路复用

发表于 2018-04-11 | 分类于 cockroachdb

结构体&函数

多路复用结构体:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
type cMux struct {
root net.Listener //net监听结构
bufLen int
errh ErrorHandler
donec chan struct{}
sls []matchersListener //协议匹配函数
}
type MuxConn struct {
net.Conn
buf bytes.Buffer
sniffer bufferedReader
}
type bufferedReader struct {
source io.Reader
buffer *bytes.Buffer
bufferRead int
bufferSize int
}
阅读全文 »

panic defer recover

发表于 2018-04-11 | 分类于 go

defer

  1. LIFO, 后进先出队列
  2. 在return语句之后,在返回上层函数之前执行
  3. 参数预编译,涉及到的参数,在定义defer的地方已经语句赋值了
1
2
3
4
5
6
7
8
func c() (i int) {
defer func() { i++ }()
return 1
}
func main() {
fmt.Println(c())
}
阅读全文 »

PG协议解析

发表于 2018-04-10 | 分类于 pg

概述

协议总体分类

  1. startup phase
  2. normal phase
    1. simple query
    2. extended query
      • prepare step
      • bind step
      • execute step
阅读全文 »

pprof发现go程序性能

发表于 2018-04-10 | 分类于 go

修改代码加入pprof

1
2
3
4
5
6
7
8
9
10
11
12
13
package main
import (
_ "net/http/pprof"
)
func main() {
// we need a webserver to get the pprof webserver
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
// your code
}
阅读全文 »

Git编译

发表于 2018-03-24 | 分类于 linux

需要安装libcurl先,不然会导致git-remote-xxx无法编译。

1
2
3
./configure
make
make install

STL vector使用不当导致内存错误

发表于 2018-01-05 | 分类于 c++

结论优先

如果在vector push back过程中出现引用元素的情况,可能导致内存问题。

阅读全文 »

gitlab配置runner

发表于 2017-12-23 | 分类于 gitlab

选一台独立机器,尽量不要和gitlab在一台机器上。

阅读全文 »

gitlab配置smtp, ldap

发表于 2017-12-22 | 分类于 gitlab

配置smtp

1
2
3
4
5
6
7
8
9
10
11
12
13
#configuration for smtp
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.mxhichina.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "gitlab@gos.com"
gitlab_rails['smtp_password'] = "xxxxxx"
gitlab_rails['smtp_domain'] = "gos.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
#gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = 'gitlab@gos.com'
#gitlab_rails['gitlab_email_reply_to'] = 'gitlab@gos.com'
阅读全文 »

crdb事务冲突处理

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

举个栗子

1
2
3
4
5
6
7
create table test.t1(c1 int primary key, c2 int);
insert into t1 values(1,1);
txn1: begin;
txn2: begin;
txn1: update t1 set c2=2 where c1=1;
txn2: select * from t1; (hang here)
阅读全文 »
123…8
Louis

Louis

记录工作和生活点滴

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