Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Durability trx #5

Merged
merged 22 commits into from
Mar 12, 2024
Merged

Durability trx #5

merged 22 commits into from
Mar 12, 2024

Conversation

hnwyllmm
Copy link
Owner

What problem were solved in this pull request?

事务模块的持久化

Mark-Song0618 and others added 22 commits February 9, 2024 16:13
### What problem were solved in this pull request?

Issue Number: close oceanbase#335 

Problem: the first set/unset bit was not found correctly.

### What is changed and how it works?
now the first set/unset bit could be found correctly.
### What problem were solved in this pull request?

Issue Number: close oceanbase#337 

Problem:

### What is changed and how it works?

add docs/src/design/miniob-mysql-protocol.md in the following documents
to remake the mdbook to make the website in the
docs/src/miniob-introduction.md correct.
> docs/src/SUMMARY.md
> docs/src/design/introduction.md

### Other information
correct the wrong address

### What problem were solved in this pull request?

Issue Number: close oceanbase#337

Problem:

### What is changed and how it works?
sorry that I use a wrong address in oceanbase#338
修正 lecture-6 两处错别字
去掉默认自动检测当前机器上CPU的个数来决定编译并发数量,改由自己决策。 
 ### What problem were solved in this pull request?
 Issue Number:  oceanbase#303
 

Problem:收到多名同学反馈编译执行buidl.sh卡死。build.sh中会自动检测当前机器上CPU的个数来决定编译并发数量,但是很多同学的机器内存与CPU并不匹配,会导致编译卡死。
 
 ### What is changed and how it works?
> 将此处改成`MAKE_ARGS=()`
>

>https://github.com/oceanbase/miniob/blob/f42235649b7d3860aaecc08265bb801b12dd7ef3/build.sh#L12


 * 去掉并发编译,使用者各取所需,在执行build.sh时直接使用 -jN 参数自行选择并行度。

 ### Other information
1. 事务日志;
2. 重启恢复;
3. 单元测试
### What problem were solved in this pull request?

Issue Number: close oceanbase#147 

Problem:
Not support with github codespace.

### What is changed and how it works?
add .devcontainer file base on oceanbase/miniob
@hnwyllmm hnwyllmm merged commit d7778f4 into durability Mar 12, 2024
hnwyllmm pushed a commit that referenced this pull request Oct 22, 2024
### What problem were solved in this pull request?

**Problem:**

When I attempted to join multiple tables, `libsanitizer` detected a
memory leak. The error log is as follows:

```
==23682==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 768 byte(s) in 12 object(s) allocated from:
    #0 0x75f738946a2a in operator new(unsigned long) /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_new_delete.cpp:95
    #1 0x56870207d56f in RowTuple::set_schema(Table const*, std::vector<FieldMeta, std::allocator<FieldMeta> > const*) /home/pepefloyd/git/miniob/src/observer/sql/expr/tuple.h:184
    #2 0x56870208f737 in TableScanPhysicalOperator::open(Trx*) /home/pepefloyd/git/miniob/src/observer/sql/operator/table_scan_physical_operator.cpp:25
    #3 0x568702081888 in NestedLoopJoinPhysicalOperator::right_next() /home/pepefloyd/git/miniob/src/observer/sql/operator/join_physical_operator.cpp:113
    #4 0x568702083b42 in PredicatePhysicalOperator::next() /home/pepefloyd/git/miniob/src/observer/sql/operator/predicate_physical_operator.cpp:41
    #5 0x56870206f411 in HashGroupByPhysicalOperator::open(Trx*) /home/pepefloyd/git/miniob/src/observer/sql/operator/hash_group_by_physical_operator.cpp:44
    #6 0x568702085740 in ProjectPhysicalOperator::open(Trx*) /home/pepefloyd/git/miniob/src/observer/sql/operator/project_physical_operator.cpp:34
    #7 0x568702038e2c in PlainCommunicator::write_result_internal(SessionEvent*, bool&) /home/pepefloyd/git/miniob/src/observer/net/plain_communicator.cpp:193
    #8 0x56870203a7cc in PlainCommunicator::write_result(SessionEvent*, bool&) /home/pepefloyd/git/miniob/src/observer/net/plain_communicator.cpp:162
    #9 0x568701ee5e4b in SqlTaskHandler::handle_event(Communicator*) /home/pepefloyd/git/miniob/src/observer/net/sql_task_handler.cpp:45
    #10 0x56870202f0d7 in Worker::operator()() /home/pepefloyd/git/miniob/src/observer/net/one_thread_per_connection_thread_handler.cpp:96
    #11 0x75f7384f78b3 in execute_native_thread_routine /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:104

SUMMARY: AddressSanitizer: 768 byte(s) leaked in 12 allocation(s).
```

### What is changed and how it works?

To fix the memory leak, I identified that in the function
`Tuple::set_schema`:

```cpp
void set_schema(const Table *table, const std::vector<FieldMeta> *fields)
{
  table_ = table;
  // fix: During a join, the right table's open is called multiple times,
  // which invokes set_schema repeatedly. This causes Tuple to store
  // unnecessary fields and values, so it is necessary to clear the existing ones first.
  this->speces_.clear();
  this->speces_.reserve(fields->size());
  for (const FieldMeta &field : *fields) {
    speces_.push_back(new FieldExpr(table, &field));
  }
}
```

The call to `this->speces_.clear()` does not destruct the existing
`FieldExpr*` objects. As a result, the memory was not released properly.
The fix I applied is to manually delete the `FieldExpr*` before clearing
the vector, as shown below:

```cpp
for (FieldExpr *spec : speces_) {
  delete spec;
}
```

This ensures that memory allocated for `FieldExpr` is properly released,
thus fixing the memory leak.
@hnwyllmm hnwyllmm deleted the durability-trx branch October 30, 2024 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants