Skip to content

Commit

Permalink
[fix](memory) Fix CloudDeltaWriter init attach task in thread context (
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyiZzz authored Mar 29, 2024
1 parent af1cddb commit 54a6030
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion be/src/cloud/cloud_delta_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CloudDeltaWriter::CloudDeltaWriter(CloudStorageEngine& engine, const WriteReques
RuntimeProfile* profile, const UniqueId& load_id)
: BaseDeltaWriter(req, profile, load_id), _engine(engine) {
_rowset_builder = std::make_unique<CloudRowsetBuilder>(engine, req, profile);
_query_thread_context.init();
}

CloudDeltaWriter::~CloudDeltaWriter() = default;
Expand All @@ -46,7 +47,7 @@ Status CloudDeltaWriter::batch_init(std::vector<CloudDeltaWriter*> writers) {
}

tasks.emplace_back([writer] {
ThreadLocalHandle::create_thread_local_if_not_exits();
SCOPED_ATTACH_TASK(writer->query_thread_context());
std::lock_guard<bthread::Mutex> lock(writer->_mtx);
if (writer->_is_init || writer->_is_cancelled) {
return Status::OK();
Expand Down
3 changes: 3 additions & 0 deletions be/src/cloud/cloud_delta_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ class CloudDeltaWriter final : public BaseDeltaWriter {

Status set_txn_related_delete_bitmap();

QueryThreadContext query_thread_context() { return _query_thread_context; }

private:
// Convert `_rowset_builder` from `BaseRowsetBuilder` to `CloudRowsetBuilder`
CloudRowsetBuilder* rowset_builder();

bthread::Mutex _mtx;
CloudStorageEngine& _engine;
QueryThreadContext _query_thread_context;
};

} // namespace doris
1 change: 0 additions & 1 deletion be/src/olap/delta_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ namespace doris {

class FlushToken;
class MemTable;
class MemTracker;
class StorageEngine;
class TupleDescriptor;
class SlotDescriptor;
Expand Down
1 change: 0 additions & 1 deletion be/src/olap/storage_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
#include "olap/tablet_meta_manager.h"
#include "olap/task/engine_task.h"
#include "olap/txn_manager.h"
#include "runtime/memory/mem_tracker.h"
#include "runtime/stream_load/stream_load_recorder.h"
#include "util/doris_metrics.h"
#include "util/metrics.h"
Expand Down
1 change: 0 additions & 1 deletion be/src/olap/storage_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class BaseCompaction;
class CumulativeCompaction;
class SingleReplicaCompaction;
class CumulativeCompactionPolicy;
class MemTracker;
class StreamLoadRecorder;
class TCloneReq;
class TCreateTabletReq;
Expand Down

0 comments on commit 54a6030

Please sign in to comment.