提交 ce481968 编写于 作者: 羽飞's avatar 羽飞 提交者: ob-robot

merge develop into master 20231220

上级 53a3cd6a
......@@ -11,7 +11,7 @@ inputs:
timeout:
description: 'timeout'
required: false
default: '7200'
default: '10800'
outputs:
success:
description: 'the status for the task'
......
The development guide is located under the [docs](docs/README.md) folder.
# Contribution Guidelines
Welcome to [oceanbase]! We're thrilled that you'd like to contribute. Your help is essential for making it better.
## Getting Started
Before you start contributing, please make sure you have read and understood our [Code of Conduct](CODE_OF_CONDUCT.md).
### Fork the Repository
First, fork the [oceanbase repository](https://github.com/oceanbase/oceanbase) to your own GitHub account. This will create a copy of the project under your account.
### Clone Your Own Repository
```bash
git clone https://github.com/`your-github-name`/oceanbase
```
### Navigate to the Project Directory 📁
```bash
cd oceanbase
```
Create a new branch for your feature or bug fix:
```bash
git checkout -b feature-branch
```
> feature-branch is the name of the branch where you will be making your changes. You can name this whatever you want.
Make your changes and commit them:
```bash
git add .
git commit -m "Description of your changes"
```
Push your changes to your fork:
```bash
git push origin feature-branch
```
Finally Click on `Compare & Pull request` to contribute on this repository.
### The Flow After You Create the Pull Request
After you create the pull request, a member of the Oceanbase team will review your changes and provide feedback. Once satisfied, they will merge your pull request.
And there are some CI checks to pass before your pull request can be merged. Currently, there are two types of CI checks:
- **Compile**: This check will compile the code on CentOS and Ubuntu.
- **Farm**: This check will run the unit tests and some mysql test cases.
> Note: If the farm failed and you think it is not related to your changes, you can ask the reviewer to re-run the farm or the reviewer will re-run the farm.
### The Flow After Your Pull Request is Merged
In default, the pull request is merged into develop branch which is the default branch of [oceanbase](https://github.com/oceanbase/oceanabse). We will merge develop into master branch periodically. So if you want to get the latest code, you can pull the master branch.
## Feature Developing
If you want to develop a new feature, you should create a [discussion](https://github.com/oceanbase/oceanbase/discussions/new/choose) first. If your idea is accepted, you can create a new issue and start to develop your feature and we will create a feature branch for you. After you finish your feature, you can create a pull request to merge your feature branch into oceanbase feature branch. The flow like below.
1. Create a [discussion](https://github.com/oceanbase/oceanbase/discussions/new/choose)
2. Create a new issue
3. Create a new feature branch on [oceanabse](https://github.com/oceanbase/oceanbase) for your feature
4. Make your changes and commit them
5. Push your changes to your fork
6. Create a pull request to merge your code into feature branch
7. After your pull request is merged, we will merge your feature branch into master
......@@ -100,6 +100,10 @@ obd demo
See also [Quick experience](https://en.oceanbase.com/docs/community-observer-en-10000000000829647) or [Quick Start (Simplified Chinese)](https://open.oceanbase.com/quickStart) for more details.
## ☸️ Start with Kubernetes
You can deploy and manage OceanBase Database instance in kubernetes cluster with [ob-operator](https://github.com/oceanbase/ob-operator) quickly. Refer to the document [Quick Start for ob-operator](https://oceanbase.github.io/ob-operator) to see details.
## 👨‍💻 Start developing
See [OceanBase Developer Document](https://github.com/oceanbase/oceanbase/wiki/Compile) to learn how to compile and deploy a manually compiled observer.
......
......@@ -99,6 +99,10 @@ obd demo
更多信息参考[快速体验 OceanBase 数据库](https://open.oceanbase.com/quickStart)
## ☸️ 使用 Kubernetes
使用 [ob-operator](https://github.com/oceanbase/ob-operator) 可在 Kubernetes 环境中快速部署和管理 OceanBase 数据库实例,可参考文档 [ob-operator 快速上手](https://oceanbase.github.io/ob-operator/README-CN.html)了解具体的使用方法。
## 👨‍💻 使用源码编译部署
参考 [OceanBase 开发者文档](https://github.com/oceanbase/oceanbase/wiki/Compile)了解如何编译和部署手动编译的observer。
......
......@@ -13,8 +13,8 @@ At present, the guide is composed of the following parts:
1. [Install toolchain](toolchain.md)
2. [Get the code, build and run](build-and-run.md)
3. Set up an IDE
4. Write and run unit tests
5. Debug and profile
4. [Write and run unit tests](unittest.md)
5. [Debug](debug.md)
6. Commit code and submit a pull request
2. **Contribute to OceanBase**: helps you quickly get involved in the OceanBase community, which illustrates what contributions you can make and how to quickly make one.
......
# Abstract
In order to easily read the code of OceanBase, we suggest using one IDE which is easily index the symbols of OceanBase. In Windows, we recommend `Souce Insight` can be used, and in Mac or Linux, we recommend that `VSCode + ccls` can be used to read the oceanbase code. Due to it is very easy to use `Source Ingisht`, so this document skip introduction how to use `Souce Insight`.
This document introduce how to setup `VSCode + ccls`, which is very convenient to read the code of OceanBase. [ccls](https://github.com/MaskRay/ccls) is based on [cquery](https://github.com/jacobdufault/cquery), which is one of C/C++/Objective-C [LSP](https://en.wikipedia.org/wiki/Language_Server_Protocol)s (In one word, LSP is used to provide programming language-specific features like code completion, syntax highlighting and marking of warnings and errors, as well as refactoring routines).
The number of OceanBase code is pretty huge and OceanBase can't be compiled under Mac or Windows, so we recommend that download the code on the remote server, and start VSCode to access the code under the remote server.
# Config ccls on Remote Server
**Attention**
The following `/path/to` just means the path example, please replace it with your real path.
## Introduction
In the C/C++ LSP domain, the famous tools are clangd and ccls. Here we recommend ccls, because:
1. The speed of building index of ccls is slower than that of clangd, but after building, the speed of accessing index of ccls is faster than that of clangd.
2. Unity building doesn't be supported by clangd, but OceanBase is being built by unity, failed to build index through compile_commands.json by clangd.
# ccls Installation
## Install ccls on CentOS
> NOTE: if you don't have the permission for `yum`, please use `sudo yum ...` instead.
```bash
yum install epel-release
yum install snapd # On centos8: yum install snapd --nobest
systemctl enable --now snapd.socket
ln -s /var/lib/snapd/snap /snap
snap install ccls --classic
```
And then add the command below into your env source file, such as '~/.bashrc' or '~/.bash_profile'
```bash
export PATH=/var/lib/snapd/snap/bin:$PATH
```
Now, refresh your environment like this:
```bash
source ~/.bashrc # or
source ~/.bash_profile
```
## Install ccls on Ubuntu
```bash
apt-get -y install ccls
```
> NOTE: If you don't have the permission, please use `sudo` as the command prefix.
## Check the Installation
You can run the command below to check whether the installation was success.
```bash
ccls --version
```
# VSCode Configuration
## Remote Plugin
Once the source code has been located in the remote machine, it is easy to setup debugging environment in remote machine. At the same time, the application can be run faster because remote machine is more powerful. User can easily access the source code on the remote machine even when something is wrong with the network, just wait reload after reconnect the remote server.
### Installation
Download and install the Remote plugin from the VSCode extension store.
![remote plugin](images/ide-settings-remote-plugin.png)
### Usage
**NOTE**:Make sure the connection between the local machine and the remote machine is fine.
After installation the plugin, there is one icon in the left bottom corner of VSCode.
![remote plugin usage](images/ide-settings-remote-plugin-usage.png)
Press the icon and select `Connect to Host`, or press shortkey `ctrl+shift+p` and select `Remote-SSH:Connect to Host`:
![connec to remote ](images/ide-settings-connect-to-remote-server.png)
Input user@remote_ip in the input frame, VSCode will create one new window, please input password in the new window:
![input password](images/ide-settings-input-password.png)
After input the password, VSCode will connect to the remote server, and it is ready to open the remote machine's file or directory.
If you want to use the specific port, please choose `Add New SSH Host`, then input ssh command, then choose one configuration file to store the ssh configuration.
![ssh port](images/ide-settings-use-different-ssh-port.png)
![ssh config file](images/ide-settings-choose-ssh-config.png)
After that, the configured machines can be found in the `Connect to Host`.
Password need to be input everytime. If you want to skip this action, please configure SSH security login with credential.
## C/C++ Plugin
We do **not** recommend using C/C++ plugins as they do not provide good indexing capabilities for OceanBase, and they are not compatible with the ccls plugin.
C/C++ plugin can be download and installed in VSCode extension store in the case of simple scenarios:
![cpp plugins](images/ide-settings-cpp-plugins.png)
C/C++ plugin can automatically code completion and syntax highlighting, but this plugin failed to build index for OceanBase, it is hard to jump the symbol of OceanBase.
## ccls Plugin
### Install ccls Plugin
![ccls plugin](images/ide-settings-ccls-plugin.png)
> if ccls will be used, it suggest to uninstall C/C++ plugin.
### Configure ccls Plugin
1. press the setting icond and choose **Extension Settings**
![ccls plugin settings](images/ide-settings-ccls-plugin-settings.png)
2. Set config ccls.index.threads. CCLS uses 80% of the system cpu cores as the parallelism in default. We can search `threads` in vscode config page and set the number like below.
> As default, oceanbase built in unity mode and it costs more memory than usual case. The system maybe hangs if the parallelism is too high such as 8C 16G system.
![ccls threads config](images/ide-settings-ccls-threads-config.png)
## Usage
1. git clone the source code from [https://github.com/oceanbase/oceanbase](https://github.com/oceanbase/oceanbase)
2. Run the command below to generate `compile_commands.json`
```bash
bash build.sh ccls --init
```
After that, compile_commands.json can be found in the directory of `code_path_of_oceanbase`.
After finish previous steps, please restart VSCode, the building index precedure can be found at the bottom of VSCode:
![ccls-indexing](images/ide-settings-ccls-indexing.png)
After finish building index, the function's reference and class member can be easily found for any opened file as the following example:
![ccls index example](images/ide-settings-ccls-index-example.png)
Recommend ccls shortkey settings:
![ccls shortkey](images/ide-settings-ccls-keyboard-settings.png)
![ccls shortkey](images/ide-settings-ccls-keyboard-settings2.png)
此差异已折叠。
# Introduction
Memory management is one of the most important modules in any large C++ project. Since OceanBase also needs to deal with the issue of multi-tenant memory resource isolation, OceanBase's memory management is more complicated than ordinary C++ projects. Generally, a good memory management module needs to consider the following issues:
- Easy to use. The designed interface must be understood and used by the container, otherwise the code will be difficult to read and maintain, and memory errors will be more likely to occur;
- Efficient. An efficient memory allocator has a crucial impact on performance, especially in high-concurrency scenarios;
- Diagnosis. As the amount of code increases, bugs are inevitable. Common memory errors, such as memory leaks, memory out-of-bounds, wild pointers and other problems cause headaches for development and operation and maintenance. How to write a function that can help us avoid or troubleshoot these problems is also an important indicator to measure the quality of the memory management module.
For the multi-tenant model, the impact of memory management design mainly includes the following aspects:
- Transparent interface design. How to make developers have no awareness or little need to care about the memory management of different tenants;
- Efficient and accurate. Sufficient memory must be applied successfully, and tenant memory exhaustion must be detected in time, which is the most basic condition for multi-tenant memory management.
This article will introduce the commonly used memory allocation interfaces and memory management related idioms in OceanBase. For technical details of memory management, please refer to [Memory Management](https://open.oceanbase.com/blog/8501613072)( In Chinese).
# Common Interfaces and Methods of OceanBase Memory Management
OceanBase provides different memory allocators for different scenarios. In addition, in order to improve program execution efficiency, there are some conventional implementations, such as reset/reuse, etc.
## ob_malloc
OceanBase has developed a set of libc-style interface functions ob_malloc/ob_free/ob_realloc. This set of interfaces will dynamically apply for memory blocks of size based on tenant_id, ctx_id, label and other attributes, and mark the memory blocks to determine ownership. This not only facilitates multi-tenant resource management, but is also very helpful in diagnosing memory problems.
ob_malloc will index to the corresponding ObTenantCtxAllocator based on tenant_id and ctx_id, and ObTenantCtxAllocator will allocate memory according to the current tenant context.
ob_free uses offset operation to find the object allocator corresponding to the memory to be released, and then returns the memory to the memory pool.
ob_realloc is different from libc's realloc. It does not expand the original address, but first copies the data to another memory through ob_malloc+memcpy, and then calls ob_free to release the original memory.
```cpp
inline void *ob_malloc(const int64_t nbyte, const ObMemAttr &attr = default_memattr);
inline void ob_free(void *ptr);
inline void *ob_realloc(void *ptr, const int64_t nbyte, const ObMemAttr &attr);
```
## OB_NEW/OB_NEWx
Similar to ob_malloc, OB_NEW provides a set of "C++" interfaces that call the object's constructor and destructor when allocating and releasing memory.
```cpp
/// T is the type, label is the memory label and it can be a const string
#define OB_NEW(T, label, ...)
#define OB_NEW_ALIGN32(T, label, ...)
#define OB_DELETE(T, label, ptr)
#define OB_DELETE_ALIGN32(T, label, ptr)
/// T is the type, pool is the memory pool allocator
#define OB_NEWx(T, pool, ...)
```
> There is no OB_DELETEx, but you can release the memory by yourself.
## ObArenaAllocator
The design feature is to allocate release multiple times and only release once. Only reset or destruction can truly release the memory. The memory allocated before will not have any effect even if `free` is actively called.
ObArenaAllocator is suitable for scenarios where many small memory allocates are released in a short period of time. For example, in a SQL request, many small block memories will be frequently allocated, and the life cycle of these small memories will last for the entire request period. Usually, the processing time of an SQL request is also very short. This memory allocation method is very effective for small memory and avoiding memory leaks. In OceanBase's code, don't be surprised if you see there is only apply for memory but cannot find a place to release it.
> Code reference `page_arena.h`
## ObMemAttr Introduction
OceanBase uses `ObMemAttr` to mark a section of memory.
```cpp
struct ObMemAttr
{
uint64_t tenant_id_; // tenant
ObLabel label_; // label or module
uint64_t ctx_id_; // refer to ob_mod_define.h, each ctx id is corresponding to a ObTenantCtxAllocator
uint64_t sub_ctx_id_; // please ignore it
ObAllocPrio prio_; // priority
};
```
> reference file alloc_struct.h
**tenant_id**
Memory allocation management perform resource statistics and restrictions based on tenant maintenance.
**label**
At the beginning, OceanBase uses a predefined method to create memory labels for each module. However, as the amount of code increases, the method of predefined labels is not suitable. Currently, ObLabel is constructed directly using constant strings. When using ob_malloc, you can also directly pass in a constant string as the ObLabel parameter, such as `buf = ob_malloc(disk_addr.size_, "ReadBuf");`.
**ctx_id**
ctx id is predefined, please refer to `alloc_struct.h`. Each ctx_id of each tenant will create an `ObTenantCtxAllocator` object, which can separately count the related memory allocation usage. Normally use `DEFAULT_CTX_ID` as ctx id. For some special modules, for example, if we want to more conveniently observe memory usage or troubleshoot problems, we define special ctx ids for them, such as libeasy communication library (LIBEASY) and Plan Cache cache usage (PLAN_CACHE_CTX_ID). We can see periodic memory statistics in log files, such as:
```txt
[2024-01-02 20:05:50.375549] INFO [LIB] operator() (ob_malloc_allocator.cpp:537) [47814][MemDumpTimer][T0][Y0-0000000000000000-0-0] [lt=10] [MEMORY] tenant: 500, limit: 9,223,372,036,854,775,807 hold: 800,768,000 rpc_hold: 0 cache_hold: 0 cache_used: 0 cache_item_count: 0
[MEMORY] ctx_id= DEFAULT_CTX_ID hold_bytes= 270,385,152 limit= 2,147,483,648
[MEMORY] ctx_id= GLIBC hold_bytes= 8,388,608 limit= 9,223,372,036,854,775,807
[MEMORY] ctx_id= CO_STACK hold_bytes= 106,954,752 limit= 9,223,372,036,854,775,807
[MEMORY] ctx_id= LIBEASY hold_bytes= 4,194,304 limit= 9,223,372,036,854,775,807
[MEMORY] ctx_id= LOGGER_CTX_ID hold_bytes= 12,582,912 limit= 9,223,372,036,854,775,807
[MEMORY] ctx_id= PKT_NIO hold_bytes= 17,969,152 limit= 9,223,372,036,854,775,807
[MEMORY] ctx_id= SCHEMA_SERVICE hold_bytes= 135,024,640 limit= 9,223,372,036,854,775,807
[MEMORY] ctx_id= UNEXPECTED_IN_500 hold_bytes= 245,268,480 limit= 9,223,372,036,854,775,807
```
**prio**
Currently, two memory allocation priorities are supported, Normal and High. The default is Normal. For definition, please refer to the `enum ObAllocPrio` in file `alloc_struct.h`. High priority memory can allocate memory from urgent (memory_reserved) memory, otherwise it cannot. Refer to `AChunkMgr::update_hold` implementation.
> You can use the configuration item `memory_reserved` to view the reserved memory size.
## init/destroy/reset/reuse
Caching is one of the important methods to improve program performance. Object reuse is also a way of caching. On the one hand, it reduces the frequency of memory allocate and release, and on the other hand, it can reduce some construction and destruction overhead. There is a lot of object reuse in OceanBase, and some conventions have been formed, such as the reset and reuse functions.
**reset**
Used to reset objects. Restore the object's state to the state after the constructor or init function was executed. For example `ObNewRow::reset`.
**reuse**
Compared with reset, it is more lightweight. Try not to release some expensive resources, such as `PageArena::reuse`.
**init/destroy**
There are two other common interfaces in OceanBase: `init` and `destroy`. `init` is used to initizalize object and `destory` to release resources. Only do some very lightweight initialization work in the constructor, such as initializing the pointer to `nullptr`.
## SMART_VAR/HEAP_VAR
SMART_VAR is an auxiliary interface for defining local variables. Variables using this interface are always allocated from the stack first. When the stack memory is insufficient, they will be allocated from the heap. For those large local variables (>8K) that are not easy to optimize, this interface not only ensures the performance of regular scenarios, but also safely reduces the stack capacity. The interface is defined as follows:
```cpp
SMART_VAR(Type, Name, Args...) {
// do...
}
```
It allocate from the stack when the following conditions are met, otherwise allocate from the heap
```cpp
sizeof(T) < 8K || (stack_used < 256K && stack_free > sizeof(T) + 64K)
```
> SMART_VAR was created to solve historical problems. It try to reduce the amount of stack memory occupied by large memory objects.
HEAP_VAR is similar to SMART_VAR, except that it must allocate memory on the heap.
## SMART_CALL
SMART_CALL is used to "quasi-transparently" resolve recursive function calls that may explode the stack on threads with very small stacks. This interface accepts a function call as a parameter. It will automatically check the current stack usage before calling the function. Once it is found that the available stack space is insufficient, a new stack execution function will be created on this thread immediately. After the function ends, it will continue to return to the original stack. This ensures performance when the stack is sufficient, and can also avoid stack explosion scenarios.
```cpp
SMART_CALL(func(args...))
```
Notice:
1. The return value of func must be an int type representing the error code.
2. SMART_CALL will return an error code. This may be an internal mechanism or a func call.
3. It supports stack cascade expansion, each time a 2M stack is expanded (there is a hard-coded total upper limit of 10M)
Compared with direct calling, SMART_CALL only call `check_stack_overflow` to check stack.
# Write and run unittest
## How to build and run all unittest?
[OceanBase](https://github.com/oceanbase/oceanbase) has two unittest directories.
- `unittest` . These are the main unittest cases, and it tests the code in the `src` directory.
- `deps/oblib/unittest`. Cases for oblib.
First, you should build `unittest`. You should enter the `unittest` directory in the build directory and build explicitly. When you build the oceanbase project, it does't build the unittest in default. For example:
```bash
bash build.sh --init --make # init and build a debug mode project
cd build_debug/unittest # or cd build_debug/deps/oblib/unittest
make -j4 # build unittest
```
Then you can execute the script file `run_tests.sh` to run all test cases.
## How to build and run a single unittest
You can also build and test a single unittest case. You can enter the `build_debug` directory, and execute `make case-name` to build the specific case and run the binary file built. For example:
```bash
cd build_debug
# **NOTE**: don't enter the unittest directory
make -j4 test_chunk_row_store
find . -name "test_chunk_row_store"
# got ./unittest/sql/engine/basic/test_chunk_row_store
./unittest/sql/engine/basic/test_chunk_row_store
```
## How to write unittest
As a C++ project, [OceanBase](https://github.com/oceanbase/oceanbase) uses [google test](https://github.com/google/googletest) as the unittest framework.
OceanBase use `test_xxx.cpp` as the unittest file name. You can create a `test_xxx.cpp` file and add the file name into the specific `CMakeLists.txt` file.
In the `test_xxx.cpp` file, you should add a header file `#include <gtest/gtest.h>` and the main function below.
```cpp
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
```
You can then add some functions to test different scenarios. Below is an example from `test_ra_row_store_projector.cpp`.
```cpp
///
/// TEST is a google test macro.
/// You can use it to create a new test function
///
/// RARowStore is the test suite name and alloc_project_fail
/// is the test name.
///
TEST(RARowStore, alloc_project_fail)
{
ObEmptyAlloc alloc;
ObRARowStore rs(&alloc, true);
/// ASSERT_XXX are some testing macros help us decide the results are
/// expected, and it will terminate the test if failed.
///
/// There are some other testing macros begin with `EXPECT_` which
/// don't terminate the test if failed.
///
ASSERT_EQ(OB_SUCCESS, rs.init(100 << 20));
const int64_t OBJ_CNT = 3;
ObObj objs[OBJ_CNT];
ObNewRow r;
r.cells_ = objs;
r.count_ = OBJ_CNT;
int64_t val = 0;
for (int64_t i = 0; i < OBJ_CNT; i++) {
objs[i].set_int(val);
val++;
}
int32_t projector[] = {0, 2};
r.projector_ = projector;
r.projector_size_ = ARRAYSIZEOF(projector);
ASSERT_EQ(OB_ALLOCATE_MEMORY_FAILED, rs.add_row(r));
}
```
Please refer to [google test document](https://google.github.io/googletest/) to get more details about `TEST`, `ASSERT` and `EXPECT`.
## Unittest on GitHub CI
Before a pull request is merged, the CI will test your pull request. The `Farm` will test the `mysql test` and `unittest`. You can see the details follow the `Details` link like below.
![github ci](images/unittest-github-ci.png)
![github ci farm details](images/unittest-ci-details.png)
![Farm unittest](images/unittest-unittest.png)
......@@ -36,59 +36,3 @@ dooba
# Changelogs
Please look into dooba script file header.
# Screenshot
## version 1.0
### dooba offline index
![screenshot v1.0](screenshot/v1_0-offline.png "screenshot for dooba v1_0 offline index")
### dooba machine
![screenshot v1.0](screenshot/v1_0-machine.png "screenshot for dooba v1_0 machine")
### dooba help
![screenshot v1.0](screenshot/v1_0-help.png "screenshot for dooba v1_0 help")
## version 0.4
### dooba shell
![screenshot v0.4](screenshot/v0_4-shell.png "screenshot for dooba v0.2 gallery")
### dooba sql
![screenshot v0.4](screenshot/v0_4-sql.png "screenshot for dooba v0.2 gallery")
### dooba UpdateServer
![screenshot v0.4](screenshot/v0_4-ups.png "screenshot for dooba v0.2 gallery")
### dooba ChunkServer
![screenshot v0.4](screenshot/v0_4-cs.png "screenshot for dooba v0.2 gallery")
## version 0.2, 0.3
### Gallery of OceanBase
![screenshot v0.2](screenshot/v0_2-gallery.png "screenshot for dooba v0.2 gallery")
### SQL of OceanBase
![screenshot v0.2](screenshot/v0_2-sql.png "screenshot for dooba v0.2 sql")
### UpdateServer of OceanBase
![screenshot v0.2](screenshot/v0_2-ups.png "screenshot for dooba v0.2 UpdateServer")
### ChunkServer of OceanBase
![screenshot v0.2](screenshot/v0_2-cs.png "screenshot for dooba v0.2 ChunkServer")
## version 0.1
![screenshot v0.1](screenshot/v0_1.png "screenshot for dooba v0.1")
......@@ -2346,12 +2346,11 @@ void ObLogInstance::reload_config_()
{
int ret = OB_SUCCESS;
ObLogConfig &config = TCONF;
const char *default_config_fpath = DEFAULT_CONFIG_FPATN;
_LOG_INFO("====================reload config begin====================");
if (OB_FAIL(config.load_from_file(default_config_fpath))) {
LOG_ERROR("load_from_file fail", KR(ret), K(default_config_fpath));
if (OB_FAIL(config.load_from_file(config.config_fpath))) {
LOG_ERROR("load_from_file fail", KR(ret), K(config.config_fpath));
} else {
CDC_CFG_MGR.configure(config);
const int64_t max_log_file_count = config.max_log_file_count;
......
......@@ -346,7 +346,7 @@ int ObTabletCreator::add_create_tablet_arg(const ObTabletCreatorArg &arg)
need_check_tablet_cnt_))) {
LOG_WARN("failed to init batch arg helper", KR(ret), K(arg));
} else if (FALSE_IT(new_arg->next_ = batch_arg)) {
} else if (OB_FAIL(args_map_.set_refactored(arg.ls_key_, new_arg, 1/*not overwrite*/))) {
} else if (OB_FAIL(args_map_.set_refactored(arg.ls_key_, new_arg, 1/*overwrite*/))) {
LOG_WARN("fail to set refactored", KR(ret), K(arg));
} else {
batch_arg = new_arg;
......
......@@ -24,7 +24,7 @@ int get_rs_status_str(const ObRootServiceStatus status,
const char *&str)
{
int ret = OB_SUCCESS;
static const char *strs[] = {"invalid", "init", "starting", "in_service", "full_service", "started",
static const char *strs[] = {"init", "starting", "in_service", "full_service", "started",
"need_stop", "stopping", "max"};
if (status < 0 || status >= MAX) {
ret = OB_INVALID_ARGUMENT;
......
......@@ -7835,8 +7835,12 @@ int ObResolverUtils::check_secure_path(const common::ObString &secure_file_priv,
{
int ret = OB_SUCCESS;
const char *access_denied_notice_message =
"Access denied, please set suitable variable 'secure-file-priv' first, such as: SET GLOBAL secure_file_priv = '/'";
if (secure_file_priv.empty() || 0 == secure_file_priv.case_compare(N_NULL)) {
ret = OB_ERR_NO_PRIVILEGE;
FORWARD_USER_ERROR_MSG(ret, "%s", access_denied_notice_message);
LOG_WARN("no priv", K(ret), K(secure_file_priv), K(full_path));
} else if (OB_UNLIKELY(secure_file_priv.length() >= DEFAULT_BUF_LENGTH)) {
ret = OB_ERR_UNEXPECTED;
......@@ -7850,6 +7854,7 @@ int ObResolverUtils::check_secure_path(const common::ObString &secure_file_priv,
stat(buf, &path_stat);
if (0 == S_ISDIR(path_stat.st_mode)) {
ret = OB_ERR_NO_PRIVILEGE;
FORWARD_USER_ERROR_MSG(ret, "%s", access_denied_notice_message);
LOG_WARN("no priv", K(ret), K(secure_file_priv), K(full_path));
} else {
MEMSET(buf, 0, sizeof(buf));
......@@ -7861,13 +7866,16 @@ int ObResolverUtils::check_secure_path(const common::ObString &secure_file_priv,
const int64_t pos = secure_file_priv_tmp.length();
if (full_path.length() < secure_file_priv_tmp.length()) {
ret = OB_ERR_NO_PRIVILEGE;
FORWARD_USER_ERROR_MSG(ret, "%s", access_denied_notice_message);
LOG_WARN("no priv", K(ret), K(secure_file_priv), K(secure_file_priv_tmp), K(full_path));
} else if (!full_path.prefix_match(secure_file_priv_tmp)) {
ret = OB_ERR_NO_PRIVILEGE;
FORWARD_USER_ERROR_MSG(ret, "%s", access_denied_notice_message);
LOG_WARN("no priv", K(ret), K(secure_file_priv), K(secure_file_priv_tmp), K(full_path));
} else if (full_path.length() > secure_file_priv_tmp.length()
&& secure_file_priv_tmp != "/" && full_path[pos] != '/') {
ret = OB_ERR_NO_PRIVILEGE;
FORWARD_USER_ERROR_MSG(ret, "%s", access_denied_notice_message);
LOG_WARN("no priv", K(ret), K(secure_file_priv), K(secure_file_priv_tmp), K(full_path));
}
}
......
......@@ -246,7 +246,11 @@ fi
if [ $? -eq 0 ]; then
echo "boot success!"
# close the enable_rich_error_msg
obclient -h127.1 -uroot@sys -A -P${OB_MYSQL_PORT} -e "alter system set enable_rich_error_msg = false;"
PASSWORD_ARG=""
if [ "${OB_ROOT_PASSWORD}" != "" ]; then
PASSWORD_ARG="-p${OB_ROOT_PASSWORD}"
fi
obclient -h127.1 -uroot@sys -A -P${OB_MYSQL_PORT} ${PASSWORD_ARG} -e "alter system set enable_rich_error_msg = false;"
else
echo "boot failed!"
if exit_while_error
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册