Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7d6a12a
feat: add gitlab-ci pipeline
donbowman Apr 5, 2020
0631c87
Merge branch 'add-gitlab-ci' into 'integration'
donbowman Apr 5, 2020
3db19b8
Merge branch 'add-stdout' into 'integration'
donbowman Apr 5, 2020
13990c1
fix: add artifacts of token
donbowman Apr 5, 2020
5e3fd59
Merge branch 'add-artifacts' into 'integration'
donbowman Apr 5, 2020
5eb3f9b
fix: add token to artifact
donbowman Apr 5, 2020
cbbf43b
Merge branch 'add-artifacts' into 'integration'
donbowman Apr 5, 2020
856a21e
Merge branch 'add-stdout' into 'integration'
donbowman Apr 8, 2020
3802e1b
Merge branch 'add-stdout' into 'integration'
donbowman Apr 8, 2020
00899e3
Merge branch 'add-stdout' into 'integration'
donbowman Apr 8, 2020
1c4d568
feat: add gitlab-ci pipeline
donbowman Apr 5, 2020
9546cd5
fix: add artifacts of token
donbowman Apr 5, 2020
1d2c93e
fix: add token to artifact
donbowman Apr 5, 2020
2d65d41
Merge branch 'rebase-upstream' into 'integration'
donbowman Aug 25, 2020
b2fde69
Merge remote-tracking branch 'upstream/master' into rebase-upstream
donbowman Mar 1, 2021
d5f10ff
Merge branch 'rebase-upstream' into 'integration'
donbowman Mar 1, 2021
aa4bf2d
fix: add container-release
donbowman Mar 1, 2021
54284f2
Merge branch 'update-pipeline' into 'integration'
donbowman Mar 1, 2021
83a4ae2
feat: add gitlab-ci pipeline
donbowman Apr 5, 2020
a38ac48
fix: add artifacts of token
donbowman Apr 5, 2020
c96e957
fix: add token to artifact
donbowman Apr 5, 2020
50a0a5f
feat: add gitlab-ci pipeline
donbowman Apr 5, 2020
a6257e6
fix: add container-release
donbowman Mar 1, 2021
a90d50f
fix: update ci + build
donbowman May 9, 2021
4b64729
Merge branch 'integration' into 'rebase'
donbowman May 9, 2021
1114b11
Merge branch 'rebase' into 'integration'
donbowman May 9, 2021
f0fa1db
fix: add redis-cli for liveness check
donbowman May 12, 2021
1e8a9d1
Merge branch 'add-redis-cli' into 'integration'
donbowman May 12, 2021
3f478d2
fix: update redis-cli to send return value
donbowman May 13, 2021
22dd9c8
fix: use upstream redis-cli
donbowman May 13, 2021
1390599
Merge branch 'update-redis-cli' into 'master'
donbowman May 13, 2021
04d3c3a
fix: do not register election leader if mocktikv is used
donbowman May 15, 2021
1cdca24
Merge branch 'allow-mock' into 'integration'
donbowman May 15, 2021
899965b
fix: correct release pipeline for integration branch
donbowman May 19, 2021
995d49c
Merge branch 'update-pipeline-release' into 'integration'
donbowman May 19, 2021
59ff75b
Merge branch 'master' into integration
donbowman May 19, 2021
4eb4c60
Merge branch 'integration' of git.agilicus.com:open-source/titan into…
donbowman May 19, 2021
0a454cc
Merge branch 'master' into integration
donbowman May 19, 2021
e55b039
fix: merge #222, updating our change
donbowman May 20, 2021
86d2d29
Merge branch 'mocktikv-task' into 'integration'
donbowman May 20, 2021
b33f94f
feat: upgrade tikv-client to v2.0.7 and remove legacy dependencies
donbowman Nov 22, 2025
0c42bfc
Merge branch 'master' into feature/tikv-client-upgrade
donbowman Nov 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Dockerfile
data
titan
token
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
./titan
titan
.idea
*.iml
*.swp
Expand All @@ -7,4 +7,6 @@ cover.cov
logs
vendor
.DS_Store
go.sum
data
titan.pid
token
42 changes: 42 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# Override any variables from /tooling/pipelines/*
variables:
DEFAULT_BRANCH: integration

stages:
- lint
- test
- build
- autorel

# Consider also nested, e.g.:

include:
- project: tooling/pipelines
ref: master
file: lint-conform.yml
- project: tooling/pipelines
ref: master
file: autorel.yml
- project: tooling/pipelines
ref: master
file: container-release.yml

go-lint:
stage: lint
image: golangci/golangci-lint:v2.6.2
script: |
go mod download
make lint

go-test:
artifacts:
paths:
- token
stage: test
image: golang:1.25.4
script: |
go mod download
make coverage
make test
make build token
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# Builder image
FROM golang:1.13.5-alpine3.11 as builder

RUN apk add --no-cache \
make \
git
FROM golang:1.25.4 as builder

COPY . /go/src/github.com/distributedio/titan

WORKDIR /go/src/github.com/distributedio/titan

RUN env GOOS=linux CGO_ENABLED=0 make
RUN \
go mod download \
&& env GOOS=linux CGO_ENABLED=0 make

# Executable image
FROM alpine
FROM alpine:3.22.2
RUN apk add redis

COPY --from=builder /go/src/github.com/distributedio/titan/titan /titan/bin/titan
COPY --from=builder /go/src/github.com/distributedio/titan/conf/titan.toml /titan/conf/titan.toml

WORKDIR /titan

ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/titan/bin

EXPOSE 7369

ENTRYPOINT ["./bin/titan"]
25 changes: 16 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
PROJECT_NAME := titan
PKG := github.com/distributedio/$(PROJECT_NAME)
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GITHASH := $(shell git rev-parse --short HEAD)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)
GO_LOGS := $(shell git log --abbrev-commit --oneline -n 1 | sed 's/$(GITHASH)//g' | sed 's/"//g' | sed "s/'//g")

LDFLAGS += -X "$(PKG)/context.ReleaseVersion=$(shell git tag --contains)"
Expand All @@ -12,16 +10,25 @@ LDFLAGS += -X "$(PKG)/context.GolangVersion=$(shell go version)"
LDFLAGS += -X "$(PKG)/context.GitLog=$(GO_LOGS)"
LDFLAGS += -X "$(PKG)/context.GitBranch=$(shell git rev-parse --abbrev-ref HEAD)"

.PHONY: all build clean test coverage lint proto
GOMINVERSION := 1.21
GOVERSION := $(shell go version | awk '{print $$3}' | tr -d 'go')

.PHONY: all build clean test coverage lint proto check-go-version
all: build token

test:
env GO111MODULE=on go test -short ${PKG_LIST}
check-go-version:
@if [ "$(shell printf '%s\n' $(GOMINVERSION) $(GOVERSION) | sort -V | head -n1)" != "$(GOMINVERSION)" ]; then \
echo "Error: Go version must be >= $(GOMINVERSION), found $(GOVERSION)"; \
exit 1; \
fi

test: check-go-version
env GO111MODULE=on go test -short ./...

coverage:
env GO111MODULE=on go test -covermode=count -v -coverprofile cover.cov ${PKG_LIST}
coverage: check-go-version
env GO111MODULE=on go test -covermode=count -v -coverprofile cover.cov ./...

build:
build: check-go-version
env GO111MODULE=on go build -ldflags '$(LDFLAGS)' -o titan ./bin/titan/

token: tools/token/main.go command/common.go
Expand All @@ -32,7 +39,7 @@ clean:
rm -rf ./token

lint:
golangci-lint run -p=bugs,complexity,format,performance,style,unused
golangci-lint run

proto:
cd ./db/zlistproto && protoc --gofast_out=plugins=grpc:. ./zlist.proto
Expand Down
26 changes: 26 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Release Notes - Titan v0.4.0

## Major Changes

- **TiKV Client Upgrade**: Upgraded from legacy `tidb/kv` to the modern `tikv/client-go/v2` library. This provides better stability, performance, and compatibility with newer TiKV clusters.
- **Go Version**: Updated requirement to Go 1.21+.

## Breaking Changes

- **GC Management**: The built-in manual GC trigger mechanism has been disabled due to API changes in the upstream client. Users are advised to rely on PD/TiKV's automatic GC or use standard TiKV tools for GC management.
- **Metrics**: Metrics dependent on the internal TiDB SDK have been removed.

## Improvements

- Improved transaction handling using modern client-go patterns.
- Updated dependencies for better security and performance.
- Simplified storage interface wrapper.

## Bug Fixes

- Fixed build issues with modern Go versions.
- Resolved dependency conflicts with `kvproto` and `etcd` (partially resolved via replacement directives).

## Upgrade Instructions

Please refer to [MIGRATION.md](MIGRATION.md) for detailed upgrade instructions.
5 changes: 3 additions & 2 deletions bin/titan/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ func ConfigureLogrus(path, level, pattern string, compress bool) error {

//Writer generate the rollingWriter
func Writer(path, pattern string, compress bool) (io.Writer, error) {
if path == "stdout" {
switch path {
case "stdout":
return os.Stdout, nil
} else if path == "stderr" {
case "stderr":
return os.Stderr, nil
}
var opts []rolling.Option
Expand Down
7 changes: 3 additions & 4 deletions bin/titan/main1_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"io/ioutil"
"os"
"path"
"testing"
Expand All @@ -18,12 +17,12 @@ func TestWriter(t *testing.T) {
assert.Equal(t, stream, os.Stderr)
assert.Nil(t, _err)

td, td_err := ioutil.TempDir("", "titan-test")
td, td_err := os.MkdirTemp("", "titan-test")
assert.Nil(t, td_err)
stream, _err = Writer(path.Join(td, "titan-test-log"), "* * * * *", true)
_, _err = Writer(path.Join(td, "titan-test-log"), "* * * * *", true)
assert.Nil(t, _err)

stream, _err = Writer(path.Join(td, "titan-test-log"), "", true)
_, _err = Writer(path.Join(td, "titan-test-log"), "", true)
assert.NotNil(t, _err)

}
26 changes: 3 additions & 23 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package titan
import (
"bufio"
"io"
"io/ioutil"
"net"
"strings"
"sync"
"time"

"github.com/distributedio/titan/command"
Expand All @@ -21,40 +19,22 @@ type client struct {
conn net.Conn
exec *command.Executor
r *bufio.Reader

eofLock sync.Mutex //the lock of reading_writing 'eof'
eof bool //is over when read data from socket
}

func newClient(cliCtx *context.ClientContext, s *Server, exec *command.Executor) *client {
return &client{
cliCtx: cliCtx,
server: s,
exec: exec,
eof: false,
}
}

func (c *client) readEof() {
c.eofLock.Lock()
defer c.eofLock.Unlock()

c.eof = true
}

func (c *client) isEof() bool {
c.eofLock.Lock()
defer c.eofLock.Unlock()

return c.eof
}

// Write to conn and log error if needed
func (c *client) Write(p []byte) (int, error) {
zap.L().Debug("write to client", zap.Int64("clientid", c.cliCtx.ID), zap.String("msg", string(p)))
n, err := c.conn.Write(p)
if err != nil {
c.conn.Close()
_ = c.conn.Close()
if err == io.EOF {
zap.L().Info("close connection", zap.String("addr", c.cliCtx.RemoteAddr),
zap.Int64("clientid", c.cliCtx.ID))
Expand Down Expand Up @@ -85,7 +65,7 @@ func (c *client) serve(conn net.Conn) error {
default:
cmd, err = c.readCommand()
if err != nil {
c.conn.Close()
_ = c.conn.Close()
if err == io.EOF {
zap.L().Info("close connection", zap.String("addr", c.cliCtx.RemoteAddr),
zap.Int64("clientid", c.cliCtx.ID))
Expand Down Expand Up @@ -121,7 +101,7 @@ func (c *client) serve(conn net.Conn) error {

// Skip reply if necessary
if c.cliCtx.SkipN != 0 {
ctx.Out = ioutil.Discard
ctx.Out = io.Discard
if c.cliCtx.SkipN > 0 {
c.cliCtx.SkipN--
}
Expand Down
Loading