Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build Docker Image

on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
tags: seekdb:latest
load: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Test Docker image
run: |
# 这里可以添加一些基本的镜像测试命令
# 例如检查镜像是否成功创建
docker images | grep seekdb
echo "Docker image built successfully"
1 change: 1 addition & 0 deletions deps/oblib/src/rpc/obrpc/ob_rpc_proxy.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ int ObRpcProxy::rpc_call(ObRpcPacketCode pcode, const Input &args,
//do nothing
}
if (dst_ == ObRpcProxy::myaddr_) {
oceanbase::lib::Thread::WaitGuard guard(oceanbase::lib::Thread::WAIT);
ret = oceanbase::oblpc::send(*this, pcode, args, result, handle, opts);
} else {
ret = OB_NOT_SUPPORTED;
Expand Down
26 changes: 26 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 使用与 GitHub Actions 相同的基础镜像
FROM ubuntu:22.04

# 设置环境变量以避免交互式提示
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC

# 设置工作目录
WORKDIR /workspace

# 安装构建所需的依赖包(与 GitHub Actions 中相同)
RUN apt-get update -y
RUN apt-get install -y git wget rpm rpm2cpio cpio make build-essential binutils m4 libtool-bin libncurses5 python3
# RUN rm -rf /var/lib/apt/lists/*
# 复制项目文件到容器中
COPY . .

# 创建构建脚本
RUN bash build.sh init

# 将 deps 目录添加到 PATH
ENV PATH="/workspace/deps/3rd/usr/local/oceanbase/devtools/bin:${PATH}"
RUN bash build.sh debug -DOB_USE_CCACHE=ON
RUN ccache -z
RUN cd build_debug && make -j$(nproc)
RUN ccache -s
Binary file modified docs/developer-guide/assets/favicon.ico
Binary file not shown.
Binary file modified docs/developer-guide/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions docs/developer-guide/en/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# OceanBase SeekDB Development Guide
# OceanBase seekdb Development Guide

## About this guide

* **The target audience** of this guide is OceanBase SeekDB contributors, both new and experienced.
* **The objective** of this guide is to help contributors become an expert of OceanBase SeekDB, who is familiar with its design and implementation and thus is able to use it fluently in the real world as well as develop OceanBase SeekDB itself deeply.
* **The target audience** of this guide is OceanBase seekdb contributors, both new and experienced.
* **The objective** of this guide is to help contributors become an expert of OceanBase seekdb, who is familiar with its design and implementation and thus is able to use it fluently in the real world as well as develop OceanBase seekdb itself deeply.

## The structure of this guide

At present, the guide is composed of the following parts:

### 1. Get Started

This section helps you set up the development environment and get OceanBase SeekDB running on your machine. Follow these steps in order if you're new to the project.
This section helps you set up the development environment and get OceanBase seekdb running on your machine. Follow these steps in order if you're new to the project.

1. [Install toolchain](toolchain.md) - Install the required development tools and dependencies
2. [Get the code, build and run](build-and-run.md) - Clone the repository, build the project, and connect to the seekdb server
Expand All @@ -21,26 +21,26 @@ This section helps you set up the development environment and get OceanBase Seek
Once you have the environment set up, these guides will help you develop effectively:

1. [Set up an IDE](ide-settings.md) - Configure your development environment for optimal productivity
2. [Coding Conventions](coding-convention.md) - Learn OceanBase SeekDB's programming habits and conventions
2. [Coding Conventions](coding-convention.md) - Learn OceanBase seekdb's programming habits and conventions
3. [Coding Standard](coding-standard.md) - Detailed C++ coding standards and constraints
4. [Write and run unit tests](unittest.md) - How to write and execute unit tests
5. [Running MySQL test](mysqltest.md) - How to run MySQL compatibility tests
6. [Debug](debug.md) - Debugging techniques and tools

### 3. Understanding the Codebase

Before you start developing a big feature, it's recommended to read these documents to better understand OceanBase SeekDB's internals:
Before you start developing a big feature, it's recommended to read these documents to better understand OceanBase seekdb's internals:

1. [Logging System](logging.md) - How logging works in OceanBase SeekDB
1. [Logging System](logging.md) - How logging works in OceanBase seekdb
2. [Memory Management](memory.md) - Memory management strategies and best practices
3. [Basic Data Structures](container.md) - Core data structures used in the codebase

### 4. Contribute to OceanBase SeekDB
### 4. Contribute to OceanBase seekdb

Ready to contribute? This guide will help you get involved in the OceanBase community:

1. [Commit code and submit a pull request](contributing.md) - Step-by-step guide to contributing code changes

---

**Note**: If you're new to the project, we recommend following the sections in order. Experienced contributors can jump directly to the sections they need.
**Note**: If you're new to the project, we recommend following the sections in order. Experienced contributors can jump directly to the sections they need.
8 changes: 4 additions & 4 deletions docs/developer-guide/en/build-and-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ git clone https://github.com/oceanbase/seekdb.git

## Build

Build OceanBase SeekDB from the source code in debug mode or release mode:
Build OceanBase seekdb from the source code in debug mode or release mode:

### Debug mode

Expand All @@ -31,7 +31,7 @@ bash build.sh release --init --make

## Run

Now that you built the `observer` binary, you can deploy a SeekDB instance with the `obd.sh` utility:
Now that you built the `observer` binary, you can deploy a seekdb instance with the `obd.sh` utility:

```shell
./tools/deploy/obd.sh prepare -p /tmp/obtest
Expand All @@ -42,13 +42,13 @@ You can check the `mysql_port` in `./tools/deploy/single.yaml` file to see the l

## Connect

You can use the official MySQL client to connect to SeekDB:
You can use the official MySQL client to connect to seekdb:

```shell
mysql -uroot -h127.0.0.1 -P10000
```

Alternatively, you can use the `obclient` to connect to SeekDB:
Alternatively, you can use the `obclient` to connect to seekdb:

```shell
./deps/3rd/u01/obclient/bin/obclient -h127.0.0.1 -P10000 -uroot -Doceanbase -A
Expand Down
26 changes: 13 additions & 13 deletions docs/developer-guide/en/coding-convention.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Coding Convention
---

OceanBase SeekDB is a giant project that has been developed for more than ten years and contains millions of lines of C++ code. It already has many unique programming habits. Here are some OceanBase SeekDB programming habits to help people who come into contact with the OceanBase SeekDB source code for the first time have an easier time accepting and understanding. For more detailed information, please refer to ["OceanBase SeekDB C++ Coding Standard"](./coding_standard.md).
OceanBase seekdb is a giant project that has been developed for more than ten years and contains millions of lines of C++ code. It already has many unique programming habits. Here are some OceanBase seekdb programming habits to help people who come into contact with the OceanBase seekdb source code for the first time have an easier time accepting and understanding. For more detailed information, please refer to ["OceanBase seekdb C++ Coding Standard"](./coding-standard.md).

# Naming Convention

Expand All @@ -20,29 +20,29 @@ Both function names and variables use lowercase naming separated by `_`. Member

# Coding Style

SeekDB uses some relatively simple coding styles to try to make the code readable and clear, such as adding necessary spaces for operator brackets, not too long codes, not too long functions, adding necessary comments, reasonable naming, etc. Since the coding style has many details, new developers can just refer to the coding style in the current code to write code. This is also a suggestion for participating in other projects for the first time. We should try to keep it consistent with the original style.
seekdb uses some relatively simple coding styles to try to make the code readable and clear, such as adding necessary spaces for operator brackets, not too long codes, not too long functions, adding necessary comments, reasonable naming, etc. Since the coding style has many details, new developers can just refer to the coding style in the current code to write code. This is also a suggestion for participating in other projects for the first time. We should try to keep it consistent with the original style.

There is no need to worry about the styles that you are not sure about. You can discuss it with us, or after submitting the code, someone will give suggestions or code together.

# Functional Coding Habits

## Prohibitting STL Containers

Since SeekDB supports multi-tenants resource isolation, in order to facilitate memory control, SeekDB prohibits the use of STL, boost and other containers. At the same time, SeekDB provides its own containers, such as `ObSEArray`, etc. For more information about SeekDB containers, please refer to [OceanBase SeekDB Container Introduction] (./container.md).
Since seekdb supports multi-tenants resource isolation, in order to facilitate memory control, seekdb prohibits the use of STL, boost and other containers. At the same time, seekdb provides its own containers, such as `ObSEArray`, etc. For more information about seekdb containers, please refer to [OceanBase seekdb Container Introduction] (./container.md).

## Be Caution with the New C++ Standard

SeekDB does not encourage the use of some syntax of the new C++ standard, such as auto, smart pointers, move semantics, range-based loops, lambda, etc. SeekDB believes that these will bring many negative effects, such as
seekdb does not encourage the use of some syntax of the new C++ standard, such as auto, smart pointers, move semantics, range-based loops, lambda, etc. seekdb believes that these will bring many negative effects, such as

- Improper use of `auto` can cause serious performance problems, but it only brings syntactic convenience;
- Smart pointers cannot solve the problem of object memory usage, and improper use can also cause performance problems;
- The use of move is extremely complex, and it will lead to deeply hidden BUGs without ensuring that everyone understands it correctly.

Of course, SeekDB does not exclude all new standards, such as encouraging the use of override, final, constexpr, etc. If you are not sure whether a certain syntax can be used, you can search and confirm in ["OceanBase SeekDB C++ Coding Standard"](./coding_standard.md).
Of course, seekdb does not exclude all new standards, such as encouraging the use of override, final, constexpr, etc. If you are not sure whether a certain syntax can be used, you can search and confirm in ["OceanBase seekdb C++ Coding Standard"](./coding-standard.md).

## Single Entrance and Single Exit

It is mandatory for all functions to return at the end, and it is prohibited to call global jump instructions such as return, goto, and exit midway. This is also the most confusing part for everyone who comes into contact with SeekDB code for the first time.
It is mandatory for all functions to return at the end, and it is prohibited to call global jump instructions such as return, goto, and exit midway. This is also the most confusing part for everyone who comes into contact with seekdb code for the first time.

In order to achieve this requirement, there will be a lot of `if/else if` in the code, and there are many less intuitive conditional judgments such as `OB_SUCC(ret)` in the `for` loop. At the same time, in order to reduce nesting, the macro `FALSE_IT` will be used to execute certain statements. for example

Expand Down Expand Up @@ -102,7 +102,7 @@ Or similar simple judgment functions do not need to return int error codes.

## Need to Determine the Validity of All Return Values and Parameters

SeekDB requires that as long as the function has a return value, the return value must be tested, and "check if possible." Function parameters, especially pointers, must be checked for validity before use.
seekdb requires that as long as the function has a return value, the return value must be tested, and "check if possible." Function parameters, especially pointers, must be checked for validity before use.

For example:

Expand All @@ -127,9 +127,9 @@ int ObDDLServerClient::abort_redef_table(const obrpc::ObAbortRedefTableArg &arg,

## Memory Management

Memory management is a very troublesome issue in C/C++ programs. SeekDB has done a lot of work for memory management, including efficient memory allocation, memory problem detection, tenant memory isolation, etc. SeekDB provides a set of memory management mechanisms for this purpose, and also prohibits the direct use of C/C++ native memory allocation interfaces in programs, such as malloc, new, etc.
Memory management is a very troublesome issue in C/C++ programs. seekdb has done a lot of work for memory management, including efficient memory allocation, memory problem detection, tenant memory isolation, etc. seekdb provides a set of memory management mechanisms for this purpose, and also prohibits the direct use of C/C++ native memory allocation interfaces in programs, such as malloc, new, etc.

The simplest, SeekDB provides the `ob_malloc/ob_free` interface to allocate and release memory:
The simplest, seekdb provides the `ob_malloc/ob_free` interface to allocate and release memory:

```cpp
void *ptr = ob_malloc(100, ObModIds::OB_COMMON_ARRAY);
Expand All @@ -143,18 +143,18 @@ if (NULL != ptr) {
}
```

SeekDB requires that the pointer must be assigned to null immediately after the memory is released.
For more information about memory management, please refer to [OceanBase SeekDB Memory Management](./memory.md).
seekdb requires that the pointer must be assigned to null immediately after the memory is released.
For more information about memory management, please refer to [OceanBase seekdb Memory Management](./memory.md).

# Some Conventional Interfaces

## init/destroy

SeekDB requires that only some very lightweight data initialization work can be implemented in the constructor, such as variables initialized to 0, pointers initialized to nullptr, etc. Because in the constructor, it is not easy to handle some complex exception scenarios, and the return value cannot be given. Most classes in SeekDB have an init function, which is usually executed after the constructor and has an int error code as the return value. Do some more complex initialization work here. Correspondingly, the destroy function is usually provided to do resource destruction.
seekdb requires that only some very lightweight data initialization work can be implemented in the constructor, such as variables initialized to 0, pointers initialized to nullptr, etc. Because in the constructor, it is not easy to handle some complex exception scenarios, and the return value cannot be given. Most classes in seekdb have an init function, which is usually executed after the constructor and has an int error code as the return value. Do some more complex initialization work here. Correspondingly, the destroy function is usually provided to do resource destruction.

## reuse/reset

Memory caching is a very effective way of improving performance. Many classes in SeekDB will have reuse/reset interfaces to facilitate the subsequent reuse of an object. Reuse usually represents lightweight cleanup work, while reset will do more resource cleanup work. But you need to look at the specific implementation class and cannot generalize.
Memory caching is a very effective way of improving performance. Many classes in seekdb will have reuse/reset interfaces to facilitate the subsequent reuse of an object. Reuse usually represents lightweight cleanup work, while reset will do more resource cleanup work. But you need to look at the specific implementation class and cannot generalize.

## Operator Overloading

Expand Down
Loading
Loading