Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


1.Should Be Exception Safe

We are moving to MODERN C++ now, and Exception Safe Code will reduce the usage of LOG(FATAL) and BE will be more stable.

1.1 Use Smart Pointer

For example, in this code, there is a raw pointer block_ptr(at line 442), and this block_ptr will pass to send_block method at line 450. It is ok in normal cases. But there is a RETURN_IF_ERROR at line 446, so it is memory leak.

...

1.2 Lock and Unlock

Use lock_guard xxxxx


2. Not Use Dynamic Arrays for Buffer


At line 62, the code create a dynamic array uint8_t meta_buff[metadata_size] as a read buffer. Dynamic array is allocated on stack and we could not make sure the size of the buffer. Sometimes it is more than 10MB. There will stack overflow.

You could use a vector or new uint8_t[metadata_size] to allocate the buffer on heap.



3. Clear EOF or EOS definitions

Currently, there are many forms that return blocks, like next_block, get_block, next_batch. And there are many ways to check if it is the last block or end of file or end of stream:

...

But currently, if eos == true, there maybe data in block. You should check if block.rows == 0.


4. Do Not Do Heavy Work in BRPC thread


bRPC is working like Coroutine, if do some heavy work or use pthread lock, it will block the network IO.  We also discourage the usage of bhtread::mutex in our code because it is maybe a pthread that using bthread::mutex. It will

...