crdb代码阅读02——system数据库初始化流程 发表于 2018-04-16 | 分类于 cockroachdb 表描述定义 pkg/sql/sqlbase/system.go 123456789101112131415161718192021UsersTable = 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 结构体&函数 多路复用结构体: 1234567891011121314151617181920type 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 LIFO, 后进先出队列 在return语句之后,在返回上层函数之前执行 参数预编译,涉及到的参数,在定义defer的地方已经语句赋值了 12345678func c() (i int) { defer func() { i++ }() return 1}func main() { fmt.Println(c())} 阅读全文 »
PG协议解析 发表于 2018-04-10 | 分类于 pg 概述 协议总体分类 startup phase normal phase simple query extended query prepare step bind step execute step 阅读全文 »
pprof发现go程序性能 发表于 2018-04-10 | 分类于 go 修改代码加入pprof 12345678910111213package mainimport ( _ "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无法编译。 123./configuremakemake install
gitlab配置smtp, ldap 发表于 2017-12-22 | 分类于 gitlab 配置smtp 12345678910111213#configuration for smtpgitlab_rails['smtp_enable'] = truegitlab_rails['smtp_address'] = "smtp.mxhichina.com"gitlab_rails['smtp_port'] = 25gitlab_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'] = falsegitlab_rails['gitlab_email_from'] = 'gitlab@gos.com'#gitlab_rails['gitlab_email_reply_to'] = 'gitlab@gos.com' 阅读全文 »
crdb事务冲突处理 发表于 2017-12-18 | 分类于 cockroachdb 举个栗子 1234567create 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) 阅读全文 »