Commit Graph

81 Commits

Author SHA1 Message Date
ad3a0fb79d [Metric] Add metrics of tablet version num distribution (#5665)
Add metrics (P50, P75, P90, P95, P99, etc.) to show the distribution of tablets version count.

```
# TYPE doris_be_tablet_version_num_distribution histogram
doris_be_tablet_version_num_distribution{quantile="0.50"} 9.21429
doris_be_tablet_version_num_distribution{quantile="0.75"} 11.7949
doris_be_tablet_version_num_distribution{quantile="0.90"} 13
doris_be_tablet_version_num_distribution{quantile="0.95"} 13
doris_be_tablet_version_num_distribution{quantile="0.99"} 13
doris_be_tablet_version_num_distribution_sum 950
doris_be_tablet_version_num_distribution_count 100
```
2021-04-23 21:23:22 +08:00
12b2447724 [Optimize] Optimize the assign logic of compaction tasks to avoid starvation (#5683)
1. Reserve a slot to ensure that the cumulative compaction can be executed.
2. Ensure that the compaction score metric can be updated.
2021-04-23 09:48:37 +08:00
be733cfa9c [Metrics] Add some large memtrackers' metric (#5614)
MemTracker can provide memory consumption for us to find out which
module consume more memory, but it's just a current value, this patch
add metrics for some large memory consumers, then we can find out
which module consume more memory in timeline, it would be useful to
troubleshoot OOM problems and optimize configs.
2021-04-21 09:15:04 +08:00
b423274f17 [Enhance] Make MemTracker more accurate (#5515) (#5516)
* [Enhance] Make MemTracker more accurate (#5515)
 This PR main about:
 1. Improve the readability of MemTrackers' name
 2. Add the MemTracker of:
    * Load
    * Compaction
    * SchemaChange
    * StoragePageCache
    * TabletManager
 3. Change SchemaChange to a Singleon

* revise some code for Code Review

* change the name of mem_tracker

* keep reader_context have the same lifetime of rowset_reader in schema change.

* change vlog notice to log(warning) in schema change
2021-04-08 09:14:55 +08:00
d641a26490 [Refactor] Remove boost filesystem (#5579)
* use std::filesystem instead of boost
Co-authored-by: Mingyu Chen <morningman.cmy@gmail.com>
2021-04-08 09:11:59 +08:00
79544d39cb [Metrics][LOG] Update metrics of 'max_compaction_score' and log for compaction (#5592)
* optimize compaction metrics and log

Co-authored-by: weizuo <weizuo@xiaomi.com>
2021-04-08 09:10:40 +08:00
422456c31a Add warn log when client report be state failed and refactor some report code (#5342)
There are some redundant code for report task, disk and tablet in be, and when fe return error report message, there is no any warn log showing report failed.

Co-authored-by: caiconghui [蔡聪辉] <caiconghui@xiaomi.com>
2021-03-03 17:00:21 +08:00
51ccd44865 [Load Parallel][3/3] Support parallel delta writer (#5369)
In the previous broker load, multiple OlapTableSinks would send data to the same LoadChannel,
and because of the lock granularity problem, LoadChannel could only process these requests serially,
which made it impossible to make full use of cluster resources.

This CL modifies the related locks so that LoadChannel can process these requests in parallel.

In the test, with a size of 20G, the load speed of 334 million rows of data in 3 nodes has been
increased from 9min to 5min, and after enabling 2 concurrency, it can be increased to 3min.

Also modify the profile of load job.
2021-02-07 22:42:18 +08:00
fd7caf775c [Bug] fix bug that dead lock may occur when drop tablet concurrent with tablet distribution interface (#5278)
Fix bug that dead lock may occur when drop tablet concurrent with calling tablet distribution interface.
2021-02-06 23:14:43 +08:00
a6e2c3e3f1 [Bug][Clone] Fix the bug that incremental clone is not triggered (#5230)
In version 0.13, we support a more efficient compaction logic. 
This logic will maintain multiple version paths of the tablet.
This can avoid -230 errors and can also support incremental clone.

But the previous incremental clone uses the incremental rowset meta recorded in `incr_rs_meta`.
At present, the incremental rowset meta recorded in `incr_rs_meta` and the records
in `stale_rs_meta` are duplicated, and the current clone logic does not adapt to the
new multi-version path, resulting in many cases not triggering incremental clone.

This CL mainly modified:

1. Removed `incr_rs_meta` metadata
2. Modified the clone logic. When the clone is incremented, it will try to read the rowset in `stale_rs_meta`.
3. Delete a lot of code that was previously used for version compatibility.
2021-02-06 22:04:48 +08:00
72ca5c5f3d [Optimize] Remove path check when start BE (#5268)
remove path check when start BE
2021-01-24 10:14:07 +08:00
93a4c7efc1 [LOG] Standardize the use of VLOG in code (#5264)
At present, the application of vlog in the code is quite confusing.
It is inherited from impala VLOG_XX format, and there is also VLOG(number) format.
VLOG(number) format does not have a unified specification, so this pr standardizes the use of VLOG
2021-01-21 12:09:09 +08:00
07eaf50084 [Feature] Add a http interface to acquire the tablets distribution between different disks (#5096)
For the task of rebalancing tablet among different disks on the same BE,
It might be an effective strategy to ensure all tablets under the same partition
evenly distribute on the different disks. Thus, it is necessary to obtain the
distribution of tablets under the same partition between different disks on a BE.

This patch add a new http interface for BE to acquire the distribution of tablets
under a partition between different disks on the same BE.
2021-01-15 09:32:27 +08:00
11c0aafa5c [UT] Speed up BE unit test (#5131)
There are some long loops and sleeps in unit tests, it will cost a
very long time to run all unit tests, especially run in TSAN mode.
This patch speed up unit tests by shortening long loops and sleeps,
on my environment all unit tests finished in 1 minite. It's useful
to do basic functional unit tests.
You can switch to run in this mode by adding a new environment variable
'DORIS_ALLOW_SLOW_TESTS'. For example, you can set:
export DORIS_ALLOW_SLOW_TESTS=1
and also you can disable it by setting:
export DORIS_ALLOW_SLOW_TESTS=0
2020-12-27 22:19:56 +08:00
86e40dd3e5 Fix old tablet inserting bug (#5113)
#4996
When BE is restarting and the older tablet have been added to the garbage collection queue but not deleted yet.
In this case, since the data_dirs are parallel loaded, a later loaded tablet may be older than previously loaded one, which should not be acknowledged as a failure.

It should be noted that the _add_tablet_unlocked() method will also be called when creating a new tablet. In that case, the changes in this pull request will not be accessed so there is no affect on the tablet creating process.
2020-12-24 15:20:54 +08:00
176dcf8bd9 [Trace] Add trace for create tablet tasks (#5091)
Add trace for create tablet tasks, it's a useful tool for admin to find
out the bottleneck when create tablets timeouted.
For example, admin could enlarge 'tablet_map_shard_size' when found
'got tablets shard lock' procedure cost too much time.
2020-12-19 11:18:12 +08:00
92db00bd86 [Bug] Fix concurrent access of _tablets_under_clone in TabletManager (#5000)
_tablets_under_clone in TabletManager is not sharded but the lock
used to prevent concurrent access is sharded, so when shards size
is not 1, it will cause coredump.
This patch fix this bug, and also do some refactor to make shard
locks more convenient to use.
2020-12-03 09:32:44 +08:00
df1f06e60b Optimized the read performance of the table when have multi versions (#4958)
* Optimized the read performance of the table when have multi versions,
changed the merge method of the unique table,
merged the cumulative version data first, and then merged with the base version.
For the data with only one base version, read directly without merging
2020-12-01 12:25:11 +08:00
6fedf5881b [CodeFormat] Clang-format cpp sources (#4965)
Clang-format all c++ source files.
2020-11-28 18:36:49 +08:00
10e1e29711 Remove header file common/names.h (#4945) 2020-11-26 17:00:48 +08:00
6247408689 [Compact]Take tablet scan frequency into consider when selecting tablet for compaction (#4837)
A large number of small segment files will lead to low efficiency for scan operations.
Multiple small files can be merged into a large file by compaction operation.
So we could take the tablet scan frequency into consideration when selecting an tablet for compaction
and preferentially do compaction for those tablets which are scanned frequently during a
latest period of time at the present.

Using the compaction strategy of Kudu for reference, scan frequency can be calculated
for tablet during a latest period of time and be taken into consideration when calculating compaction score.
2020-11-18 21:51:12 +08:00
f239f44b37 [Compaction][Bug-Fix] Fix bug that meta lock need to be held when calculating compaction score (#4829)
* [Compaction][Buf] Fix bug that meta lock need to be held when calucating compaction score

* fix

Co-authored-by: morningman <chenmingyu@baidu.com>
2020-11-05 20:29:01 +08:00
d1c2b3ed0d [Optimize] Add an unordered_map for TabletSchema to speed up column name lookup (#4779)
Reduce column name lookup for TabletSchema and Tablet from O(N) to O(1).
2020-11-03 19:53:44 +08:00
6790254b97 [Bug] Fix bug and optimize implementation logic of tablets web page (#4775)
(1) The implementation logic of `tablets web page` is that:
Firstly, get all the tablets of the BE;
Secondly, return specific number tablets in front to web page according to the value of request parameter `limit`. 
This patch optimize the implementation logic of `tablets web page` that getting specific number tablets in BE 
according to the value of request parameter `limit` and then return them to web page.

(2) It will return default `1000` tablets through http interface `http://be_host:webserver_port/tablets_page`.
If the number of tablet in the BE is less than 1000, there will be `coredump` in the following code:

be/src/http/action/tablets_info_action.cpp
2020-10-28 23:25:43 +08:00
77835dd9c4 [Bug][Compaction] Fix bug that compaction may be blocked (#4750)
the logic of compaction producer thread may failed to produce compaction task due to
invalid order of modifying task map.
2020-10-21 10:12:37 +08:00
09f97f8a05 [Refactor] Fixes some be typo part 2 (#4747) 2020-10-20 09:28:57 +08:00
eba595583e [Optimize] Optimize the execution model of compaction to limit memory consumption (#4670)
Currently, there are M threads to do base compaction and N threads to do cumulative compaction for each disk. 
Too many compaction tasks may run out of memory, so the max concurrency of running compaction tasks
is limited by semaphore.
If the running threads cost too much memory, we can't defense it. In addition, reducing concurrency to avoid OOM
will lead to some compaction tasks can't be executed in time and we may encounter more heavy compaction. 
Therefore, concurrency limitation is not enough.

The strategy proposed in #3624  may be effective to solve the OOM. 

A CompactionPermitLimiter is used for compaction limitation, and use single-producer/multi-consumer model.
Producer will try to generate compaction tasks and acquire `permits` for each task. 
The compaction task which can hold `permits` will be executed in thread pool and each finished task will
release its `permits`.

`permits` should be applied for before a compaction task can execute. When the sum of `permits`
held by executing compaction tasks reaches a threshold, subsequent compaction task will be no longer allowed,
until some `permits` are released. Tablet compaction score is used as `permits` of compaction task here.

To some extent, memory consumption can be limited by setting appropriate `permits` threshold.
2020-10-11 11:39:25 +08:00
498b06fbe2 [Metrics] Support tablet level metrics (#4428)
Sometimes we want to detect the hotspot of a cluster, for example, hot scanned tablet, hot wrote tablet,
but we have no insight about tablets in the cluster.
This patch introduce tablet level metrics to help to achieve this object, now support 4 metrics on tablets: `query_scan_bytes `, `query_scan_rows `, `flush_bytes `, `flush_count `. 
However, one BE may holds hundreds of thousands of tablets, so I add a parameter for the metrics HTTP request,
and not return tablet level metrics by default.
2020-09-02 10:39:41 +08:00
b85bb0e2e9 [Bug-Fix] Some deleted tablets are not recycled on BE (#4401) 2020-08-27 12:09:19 +08:00
d655b271b8 [Feature][Web] Add new feature to list all tablets on a particular BE (#4268)
A new feature has been added to acquire tablet id and schema hash of all the tablets on a particular BE node
via Web page,so that more detailed information of each tablet can be obtained according to these
tablet id and schema hash. In accordance with different web request, there are two ways 
(table and json)to show these acquired tablet id and schema hash on Web page.
2020-08-12 20:55:19 +08:00
03cf9b2a24 [Compaction] Add delayed deletion of rowsets function, fix -230 error. (#4039)
Related issue #4017, main changes as follows:
1. Add expired_snapshot_rs_version_map,_expired_snapshot_rs_metas,
2. Add  VersionedRowsetTracker record compacted path version
3. Record path version when rowsets compact
4. In gc process, add expired snapshot rowsets to unused set to remove.
2020-07-19 22:03:59 +08:00
93a0b47d22 Revert "[Memory Engine] MemTablet creation and compatibility handling in BE (#3762)" (#3931)
This reverts commit ca96ea30560c9e9837c28cfd2cdd8ed24196f787.
2020-06-24 10:13:45 +08:00
ca96ea3056 [Memory Engine] MemTablet creation and compatibility handling in BE (#3762) 2020-06-18 09:56:07 +08:00
3b6a781862 [Bug] Fix a bug that tablet's _preferred_rowset_type may be modified to BETA_ROWSET after cloned (#3750)
TabletMeta's _preferred_rowset_type is not initialized after object constructing and
may be a random value, and this field is not updated when create ALPHA_ROWSET tablet,
and it will not be serialized into pb in this case. So if cloning an ALPHA_ROWSET
tablet from another BE, this new created local tablet's _preferred_rowset_type field
may be random as BETA_ROWSET and can not be overwrote after cloned, then new input
rows will be wrote as BETA_ROWSET format which is not we expect.
This patch fix this bug by giving _preferred_rowset_type a default value and updating
this field when create any type of tablet, and add an unit test and related overwrite
equal operator functions.
2020-06-06 11:36:28 +08:00
f6b5c8839b [Bug] Ignore loading DELETE status tablet error when restarting BE (#3641)
Fix: #3640 

Also add a `batch delete meta` feature for `meta tool`
Fix #3639
2020-05-21 19:08:28 +08:00
273aad6cf4 [Bug] Restore tablet action not working because tablet status is shutdown (#3551) 2020-05-15 10:11:17 +08:00
a5922051c9 [Fix] Fix bug that rowset meta is deleted after compaction (#3451)
* [Fix] Fix bug that rowset meta is deleted after compaction

After compaction, the tablet rowset meta will be modified by
adding to new output rowsets and deleting the old input rowsets.
The output version may equals to the input version.

So we should delete the "input" version from _rs_version_map
before adding the "output" version to _rs_version_map. Otherwise,
the new "output" version will be lost in _rs_version_map.
2020-05-04 09:45:25 +08:00
b58b1b3953 [metrics] Make DorisMetrics to be a real singleton (#3417) 2020-05-04 09:20:53 +08:00
37fccd53c4 [Tablet] A small refactor on class Tablet (#3339)
There is no functional changes in this patch.
Key refactor points are:
- Remove meaningless return value of functions in class Tablet, and
  also some related functions in other classes
- Allow RowsetGraph::capture_consistent_versions to pass a nullptr
  to the output parameter
- Use CHECK instead of LOG(FATAL) to simplify code
2020-04-24 22:22:26 +08:00
be090f5929 Use read lock when iterate tablet_map in TabletManager::start_trash_sweep (#3294) 2020-04-13 11:18:33 +08:00
f39c8b156d [refactor] A small refactor on class DataDir (#3276)
main refactor points are:
- Use a single get_absolute_tablet_path function instead of 3
  independent functions
- Remove meaningless return value of register_tablet and deregister_tablet
- Some typo and format
2020-04-10 00:32:22 +08:00
a5703ef114 [Performance] Support sharding txn_map_lock into more small map locks to make good performance for txn manage task (#3222)
This PR is to enhance the performance for txn manage task, when there are so many txn in 
BE, the only one txn_map_lock and additional _txn_locks may cause poor performance, and 
now we remove the additional _txn_locks and split the txn_map_lock into many small locks.
2020-04-09 22:35:15 +08:00
d110629a5f Optimize performance of TxnManager::build_expire_txn_map (#3269)
It's not possible to insert duplicated transaction ids for a specific tablet, therefore we could use map<TabletInfo, vector<int64_t>> instead of map<TabletInfo, set<int64_t>> for expire_txn_map.
2020-04-07 23:54:05 +08:00
8aa8b8c96d [Code Refactor] Using block manager to unify the data file access. (#3189)
Earlier we introduced `BlockManager` to separate data access logic from
underlying file read and write logic.

This CL further unifies all `SegmentV2` data access to the `BlockManager`, 
removes the previous `FileManager` class, and move the file cache to the `FileBlockManager`.

There are no logical changes to this CL.

After this CL, all user table data is read through the `WritableBlock` and `ReadableBlock` 
returned by the `BlockManager`, and no file operations are performed directly.
2020-03-25 20:39:07 +08:00
178bdcb16a Use DCHECK_GT instead when checking _tablet_map_lock_shard_size (#3138) 2020-03-18 19:41:04 +08:00
64a06ea9d4 [UT] Fix some BE unit tests (#3110)
And also support graceful exit for StorageEngine to avoid hang too long
time in unit test.
2020-03-16 13:31:44 +08:00
a1f5b57011 Support sharding tablet_map_lock into more small map locks to make good performance for tablet manage task (#3051)
Support sharding tablet_map_lock into more small map locks to make good performance for tablet manage task
2020-03-09 16:29:56 +08:00
feef077520 Some refactors on TabletManager (#2918)
1. Add some comments to make the code easier to understand;
2. Make the metric `create_tablet_requests_failed` to be accurate;
3. Some internal methods use naked pointers directly instead of `shared_ptr`;
4. The `using` in `.h` files are contagious when included by other files,
    so we should only use it in `.cpp` files;
5. Some formatting changes: such as wrapping lines that are too long
6. Parameters that need to be modified, use pointers instead of references

No functional changes in this patch.
2020-02-17 14:50:29 +08:00
5440e19d01 Improve the triggering strategy of BE report (#2881)
Currently, the report from BE to FE is completed in the background
threads of `AgentServer` (`report_tablet_thread` and
`report_disk_stat_thread`).  These two threads will sleep and be in
a standby state after each report, if there is any need to report
immediately, they will be notified and wake up immediately to report.

For example, when background thread (`disk_monitor_thread`) in
`StorageEngine` finds some tablets were deleted, it will notify
`AgentServer` to trigger a report immediately.

In the current implementation, in order to report ASAP, a local variable
(`_is_drop_tables`) and two other flags are used to record whether
reporting is needed, and then `StorageEngine::disk_monitor_thread` checks
the value of this variable every time it runs, to determine whether it
needs to be triggered Reporting. This is actually superfluous, and it
may result in untimely notifications, as shown below:

```
(thread_1)        (thread_2)
disk-monitor     disk-stat-reporter
    |                  |
    |               reporting
    |                  |
  notify_1             |
    |                  |
    |                wait_for_notify(will wait until timeout or next notification)
    |                  |
    V                  V
```

When `report_tablet_thread` has not started waiting,
`StorageEngine::disk_monitor_thread` triggers a notification, so this
notification will not be received by `report_tablet_thread`,
resulting in the BE not reporting to the FE until the lock times out
or the next round of `disk_monitor_thread` detection.

This change restructures the triggering implementation, and solves the above problem.

This change also changes some methods(that do not need to be public) to private.
2020-02-11 20:38:44 +08:00
77805e85d2 Fix lock type when clear trash (#2868)
In `TabletManager::start_trash_swee`, the modification of `_tablet_map`
should be protected by `write-lock` of `_tablet_map_lock`
2020-02-10 13:14:17 +08:00