Merge branch 'master' into develop
This commit is contained in:
@ -4,19 +4,19 @@ In order to easily read the code of OceanBase, we suggest using one IDE which is
|
||||
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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
|
||||
|
||||
@ -26,7 +26,7 @@ In the C/C++ LSP domain, the famous tools are clangd and ccls. Here we recommend
|
||||
|
||||
```bash
|
||||
yum install epel-release
|
||||
yum install snapd # On centos8: yum install snapd --nobest
|
||||
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
|
||||
@ -65,7 +65,7 @@ ccls --version
|
||||
|
||||
## 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.
|
||||
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
|
||||
|
||||
@ -75,8 +75,8 @@ Download and install the Remote plugin from the VSCode extension store.
|
||||
|
||||
### 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.
|
||||
**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.
|
||||
|
||||

|
||||
|
||||
@ -88,16 +88,16 @@ Input user@remote_ip in the input frame, VSCode will create one new window, plea
|
||||
|
||||

|
||||
|
||||
After input the password, VSCode will connect to the remote server, and it is ready to open the remote machine's file or directory.
|
||||
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.
|
||||
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.
|
||||
|
||||

|
||||
|
||||

|
||||
After that, the configured machines can be found in the `Connect to Host`.
|
||||
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.
|
||||
Password need to be input everytime. If you want to skip this action, please configure SSH security login with credential.
|
||||
|
||||
## C/C++ Plugin
|
||||
|
||||
@ -106,7 +106,7 @@ We do **not** recommend using C/C++ plugins as they do not provide good indexing
|
||||
C/C++ plugin can be download and installed in VSCode extension store in the case of simple scenarios:
|
||||
|
||||

|
||||
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.
|
||||
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
|
||||
|
||||
@ -114,7 +114,7 @@ C/C++ plugin can automatically code completion and syntax highlighting, but this
|
||||
|
||||

|
||||
|
||||
> if ccls will be used, it suggest to uninstall C/C++ plugin.
|
||||
> if ccls will be used, it suggest to uninstall C/C++ plugin.
|
||||
|
||||
### Configure ccls Plugin
|
||||
|
||||
@ -132,7 +132,7 @@ C/C++ plugin can automatically code completion and syntax highlighting, but this
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
@ -123,35 +123,35 @@ Among the example, "start stmt" is the `INFO` information, and we uses the `K` m
|
||||
A output of the example code above:
|
||||
|
||||
```text
|
||||
[2023-12-11 18:00:55.711877] INFO [SQL.EXE] start_stmt (ob_sql_trans_control.cpp:619)
|
||||
[99178][T1004_TeRec][T1003][YD9F97F000001-00060C36119D4757-0-0] [lt=15]
|
||||
start stmt(ret=0, auto_commit=true, session_id=1,
|
||||
snapshot={this:0x7f3184fca0e8, valid:true, source:2,
|
||||
core:{version:{val:1702288855549635029, v:0}, tx_id:{txid:167035},
|
||||
scn:1702288855704049}, uncertain_bound:0, snapshot_lsid:{id:1},
|
||||
snapshot_ls_role:0, parts:[{left:{id:1}, right:491146514786417}]},
|
||||
savepoint=1702288855704049, tx_desc={this:0x7f31df697420,
|
||||
tx_id:{txid:167035}, state:2, addr:"127.0.0.1:55801", tenant_id:1003,
|
||||
session_id:1, assoc_session_id:1, xid:NULL, xa_mode:"",
|
||||
xa_start_addr:"0.0.0.0:0", access_mode:0, tx_consistency_type:0,
|
||||
isolation:1, snapshot_version:{val:18446744073709551615, v:3},
|
||||
snapshot_scn:0, active_scn:1702288855704040, op_sn:6, alloc_ts:1702288855706134,
|
||||
active_ts:1702288855706134, commit_ts:-1, finish_ts:-1, timeout_us:29999942,
|
||||
lock_timeout_us:-1, expire_ts:1702288885706076, coord_id:{id:-1},
|
||||
parts:[{id:{id:1}, addr:"127.0.0.1:55801", epoch:491146514786417,
|
||||
first_scn:1702288855704043, last_scn:1702288855704048, last_touch_ts:1702288855704044}],
|
||||
exec_info_reap_ts:1702288855704043, commit_version:{val:18446744073709551615, v:3},
|
||||
commit_times:0, commit_cb:null, cluster_id:1, cluster_version:17180065792,
|
||||
flags_.SHADOW:false, flags_.INTERRUPTED:false, flags_.BLOCK:false,
|
||||
flags_.REPLICA:false, can_elr:true, cflict_txs:[], abort_cause:0,
|
||||
commit_expire_ts:0, commit_task_.is_registered():false, ref:2},
|
||||
plan_type=1, stmt_type=5, has_for_update=false, query_start_time=1702288855711692,
|
||||
use_das=false, nested_level=0, session={this:0x7f31de2521a0, id:1,
|
||||
deser:false, tenant:"sys", tenant_id:1, effective_tenant:"sys",
|
||||
effective_tenant_id:1003, database:"oceanbase", user:"root@%",
|
||||
consistency_level:3, session_state:0, autocommit:true, tx:0x7f31df697420},
|
||||
plan=0x7f31565ba050, consistency_level_in_plan_ctx=3,
|
||||
trans_result={incomplete:false, parts:[], touched_ls_list:[],
|
||||
[2023-12-11 18:00:55.711877] INFO [SQL.EXE] start_stmt (ob_sql_trans_control.cpp:619)
|
||||
[99178][T1004_TeRec][T1003][YD9F97F000001-00060C36119D4757-0-0] [lt=15]
|
||||
start stmt(ret=0, auto_commit=true, session_id=1,
|
||||
snapshot={this:0x7f3184fca0e8, valid:true, source:2,
|
||||
core:{version:{val:1702288855549635029, v:0}, tx_id:{txid:167035},
|
||||
scn:1702288855704049}, uncertain_bound:0, snapshot_lsid:{id:1},
|
||||
snapshot_ls_role:0, parts:[{left:{id:1}, right:491146514786417}]},
|
||||
savepoint=1702288855704049, tx_desc={this:0x7f31df697420,
|
||||
tx_id:{txid:167035}, state:2, addr:"127.0.0.1:55801", tenant_id:1003,
|
||||
session_id:1, assoc_session_id:1, xid:NULL, xa_mode:"",
|
||||
xa_start_addr:"0.0.0.0:0", access_mode:0, tx_consistency_type:0,
|
||||
isolation:1, snapshot_version:{val:18446744073709551615, v:3},
|
||||
snapshot_scn:0, active_scn:1702288855704040, op_sn:6, alloc_ts:1702288855706134,
|
||||
active_ts:1702288855706134, commit_ts:-1, finish_ts:-1, timeout_us:29999942,
|
||||
lock_timeout_us:-1, expire_ts:1702288885706076, coord_id:{id:-1},
|
||||
parts:[{id:{id:1}, addr:"127.0.0.1:55801", epoch:491146514786417,
|
||||
first_scn:1702288855704043, last_scn:1702288855704048, last_touch_ts:1702288855704044}],
|
||||
exec_info_reap_ts:1702288855704043, commit_version:{val:18446744073709551615, v:3},
|
||||
commit_times:0, commit_cb:null, cluster_id:1, cluster_version:17180065792,
|
||||
flags_.SHADOW:false, flags_.INTERRUPTED:false, flags_.BLOCK:false,
|
||||
flags_.REPLICA:false, can_elr:true, cflict_txs:[], abort_cause:0,
|
||||
commit_expire_ts:0, commit_task_.is_registered():false, ref:2},
|
||||
plan_type=1, stmt_type=5, has_for_update=false, query_start_time=1702288855711692,
|
||||
use_das=false, nested_level=0, session={this:0x7f31de2521a0, id:1,
|
||||
deser:false, tenant:"sys", tenant_id:1, effective_tenant:"sys",
|
||||
effective_tenant_id:1003, database:"oceanbase", user:"root@%",
|
||||
consistency_level:3, session_state:0, autocommit:true, tx:0x7f31df697420},
|
||||
plan=0x7f31565ba050, consistency_level_in_plan_ctx=3,
|
||||
trans_result={incomplete:false, parts:[], touched_ls_list:[],
|
||||
cflict_txs:[]})
|
||||
```
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ SMART_VAR(Type, Name, Args...) {
|
||||
|
||||
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)
|
||||
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.
|
||||
|
||||
@ -15,7 +15,7 @@ mysqltest is a test in the OceanBase database access test. Simply put, it takes
|
||||
When running the mysqltest test, it is divided into different modes according to the selected nodes. The common mysqltest modes are as follows.
|
||||
|
||||
* c mode: Connect to the server where the Primary Zone is located to run mysqltest. For example, use the configuration file distributed.yaml to deploy the cluster and then connect to server1 to run the test.
|
||||
|
||||
|
||||
```shell
|
||||
./obd.sh mysqltest -n <name> --suite acs --test-server=server1
|
||||
```
|
||||
@ -43,21 +43,21 @@ Please refer to [build-and-run](./build-and-run.md) to compile the OceanBase dat
|
||||
You can choose to test in full or specify a `case` or `suite` for testing. For the specific meaning of parameters used when executing the obd.sh script, please refer to [Appendix](#Appendix).
|
||||
|
||||
* Full test, that is, run all suites in the `mysql_test/test_suite` directory, please refer to the following command.
|
||||
|
||||
|
||||
```shell
|
||||
[admin@obtest ~]$ cd oceanbase/tools/deploy
|
||||
[admin@obtest deploy]$ ./obd.sh mysqltest -n test --all
|
||||
```
|
||||
|
||||
* Specify case for testing, for example, specify `mysql_test/test_suite/alter/t/alter_log_archive_option.test`. Please refer to the following command.
|
||||
|
||||
|
||||
```shell
|
||||
[admin@obtest ~]$ cd oceanbase/tools/deploy
|
||||
[admin@obtest deploy]$ ./obd.sh mysqltest -n test --test-dir ./mysql_test/test_suite/alter/t --result-dir ./mysql_test/test_suite/alter/r --test-set alter_log_archive_option
|
||||
```
|
||||
|
||||
* To specify a suite test, for example, to execute a test on a specified suite in the `mysql_test/test_suite` directory, please refer to the following command.
|
||||
|
||||
|
||||
```shell
|
||||
[admin@obtest ~]$ cd oceanbase/tools/deploy
|
||||
[admin@obtest deploy]$ ./obd.sh mysqltest -n test --suite acs
|
||||
|
||||
@ -33,7 +33,7 @@ find . -name "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.
|
||||
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.
|
||||
|
||||
@ -51,7 +51,7 @@ You can then add some functions to test different scenarios. Below is an example
|
||||
|
||||
```cpp
|
||||
///
|
||||
/// TEST is a google test macro.
|
||||
/// 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
|
||||
@ -62,10 +62,10 @@ TEST(RARowStore, alloc_project_fail)
|
||||
ObEmptyAlloc alloc;
|
||||
ObRARowStore rs(&alloc, true);
|
||||
|
||||
/// ASSERT_XXX are some testing macros help us decide the results are
|
||||
/// 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
|
||||
/// 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));
|
||||
|
||||
Reference in New Issue
Block a user