[Enhancement] support write starlet file with tag (#61605)

Signed-off-by: starrocks-xupeng <xupeng@starrocks.com>
Signed-off-by: 絵空事スピリット <wanglichen@starrocks.com>
Co-authored-by: 絵空事スピリット <wanglichen@starrocks.com>
This commit is contained in:
starrocks-xupeng 2025-08-11 22:32:43 +08:00 committed by GitHub
parent f8e7371c48
commit 26ade294ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 65 additions and 4 deletions

View File

@ -1131,6 +1131,7 @@ CONF_Alias(object_storage_request_timeout_ms, starlet_fslib_s3client_request_tim
CONF_mInt32(starlet_delete_files_max_key_in_batch, "1000");
CONF_mInt32(starlet_filesystem_instance_cache_capacity, "10000");
CONF_mInt32(starlet_filesystem_instance_cache_ttl_sec, "86400");
CONF_mBool(starlet_write_file_with_tag, "false");
#endif
CONF_mInt64(lake_metadata_cache_limit, /*2GB=*/"2147483648");

View File

@ -38,6 +38,7 @@
#include "io/throttled_output_stream.h"
#include "io/throttled_seekable_input_stream.h"
#include "service/staros_worker.h"
#include "storage/lake/filenames.h"
#include "storage/olap_common.h"
#include "util/defer_op.h"
#include "util/stopwatch.hpp"
@ -65,6 +66,11 @@ using WritableFilePtr = std::unique_ptr<staros::starlet::fslib::WritableFile>;
using Anchor = staros::starlet::fslib::Stream::Anchor;
using EntryStat = staros::starlet::fslib::EntryStat;
static const std::string kFileTagType = "type";
static const std::string kFileTagTypeData = "data";
static const std::string kFileTagTypeMeta = "meta";
static const std::string kFileTagTypeTxnLog = "txnlog";
bool is_starlet_uri(std::string_view uri) {
return HasPrefixString(uri, "staros://");
}
@ -370,6 +376,15 @@ public:
staros::starlet::fslib::WriteOptions fslib_opts;
fslib_opts.create_missing_parent = true;
fslib_opts.skip_fill_local_cache = opts.skip_fill_local_cache;
if (config::starlet_write_file_with_tag) {
if (lake::is_segment(pair.first)) {
fslib_opts.tags[kFileTagType] = kFileTagTypeData;
} else if (lake::is_tablet_metadata(pair.first)) {
fslib_opts.tags[kFileTagType] = kFileTagTypeMeta;
} else if (lake::is_txn_log(pair.first) || lake::is_combined_txn_log(pair.first)) {
fslib_opts.tags[kFileTagType] = kFileTagTypeTxnLog;
}
}
auto file_st = (*fs_st)->create(pair.first, fslib_opts);
if (!file_st.ok()) {
return to_status(file_st.status());

View File

@ -412,6 +412,24 @@ TEST_P(StarletFileSystemTest, test_delete_files) {
(void)g_worker->remove_shard(shard_info.id);
}
TEST_P(StarletFileSystemTest, test_tag) {
bool old = config::starlet_write_file_with_tag;
config::starlet_write_file_with_tag = true;
auto uri1 = StarletPath("tag.dat");
ASSIGN_OR_ABORT(auto fs, FileSystem::CreateSharedFromString(uri1));
ASSIGN_OR_ABORT(auto wf1, fs->new_writable_file(uri1));
auto uri2 = StarletPath("tag.meta");
ASSIGN_OR_ABORT(auto wf2, fs->new_writable_file(uri2));
auto uri3 = StarletPath("tag.log");
ASSIGN_OR_ABORT(auto wf3, fs->new_writable_file(uri3));
auto uri4 = StarletPath("tag.logs");
ASSIGN_OR_ABORT(auto wf4, fs->new_writable_file(uri4));
config::starlet_write_file_with_tag = old;
}
INSTANTIATE_TEST_CASE_P(StarletFileSystem, StarletFileSystemTest,
::testing::Values(std::string("s3"), std::string("cachefs")));

View File

@ -3619,6 +3619,15 @@ When this value is set to less than `0`, the system uses the product of its abso
- Description: The cache expiration time of starlet filesystem instances.
- Introduced in: v3.3.15, 3.4.5
##### starlet_write_file_with_tag
- Default: false
- Type: Boolean
- Unit: -
- Is mutable: Yes
- Description: In a shared-data cluster, whether to tag files written to object storage with object storage tags for convenient custom file management.
- Introduced in: v3.5.3
##### lake_compaction_stream_buffer_size_bytes
- Default: 1048576

View File

@ -1823,6 +1823,15 @@ curl http://<BE_IP>:<BE_HTTP_PORT>/varz
- 説明: starlet filesystem インスタンス キャッシュの有効期限。
- 導入バージョン: v3.3.15, 3.4.5
##### starlet_write_file_with_tag
- デフォルト: false
- タイプ: Boolean
- 単位: -
- 可変: はい
- 説明: 共有データクラスターにおいて、オブジェクトストレージに書き込まれたファイルにオブジェクトストレージタグを付与し、便利なカスタムファイル管理を行うかどうか。
- 導入バージョン: v3.5.3
##### lake_compaction_stream_buffer_size_bytes
- デフォルト: 1048576

View File

@ -3557,7 +3557,7 @@ curl http://<BE_IP>:<BE_HTTP_PORT>/varz
- 类型Int
- 单位Milliseconds
- 是否动态:否
- 配置项描述: `object_storage_request_timeout_ms` 的别名。详细信息请参考配置项 [object_storage_request_timeout_ms](#object_storage_request_timeout_ms)。
- 描述: `object_storage_request_timeout_ms` 的别名。详细信息请参考配置项 [object_storage_request_timeout_ms](#object_storage_request_timeout_ms)。
- 引入版本: v3.3.9
##### starlet_filesystem_instance_cache_capacity
@ -3566,7 +3566,7 @@ curl http://<BE_IP>:<BE_HTTP_PORT>/varz
- 类型Int
- 单位:-
- 是否动态:是
- 配置项描述: starlet filesystem 实例的缓存容量。
- 描述: starlet filesystem 实例的缓存容量。
- 引入版本: v3.2.16, v3.3.11, v3.4.1
##### starlet_filesystem_instance_cache_ttl_sec
@ -3575,9 +3575,18 @@ curl http://<BE_IP>:<BE_HTTP_PORT>/varz
- 类型Int
- 单位:秒
- 是否动态:是
- 配置项描述: starlet filesystem 实例缓存的过期时间。
- 描述: starlet filesystem 实例缓存的过期时间。
- 引入版本: v3.3.15, 3.4.5
##### starlet_write_file_with_tag
- 默认值false
- 类型Boolean
- 单位:-
- 是否动态:是
- 描述: 存算分离集群下,是否将写入到对象存储的文件打上对象存储 Tag方便自定义管理文件。
- 引入版本: v3.5.3
##### lake_compaction_stream_buffer_size_bytes
- 默认值1048576
@ -5333,4 +5342,4 @@ curl http://<BE_IP>:<BE_HTTP_PORT>/varz
- 默认值: 100
- 类型: -
- 是否动态: 否
- 描述: table metrics中表的最大数量, metrics/接口最多返回max_table_metrics_num个表的metrics。
- 描述: table metrics中表的最大数量, metrics/接口最多返回max_table_metrics_num个表的metrics。