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

bug: The default file_limit is 48, but they don't delete exprise files #16702

Closed
1 of 2 tasks
wubx opened this issue Oct 28, 2024 · 1 comment
Closed
1 of 2 tasks

bug: The default file_limit is 48, but they don't delete exprise files #16702

wubx opened this issue Oct 28, 2024 · 1 comment
Labels
C-bug Category: something isn't working

Comments

@wubx
Copy link
Member

wubx commented Oct 28, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

Version

main

What's Wrong?

The log default file_limit is 48, but they don;t delete exprise files.

How to Reproduce?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@wubx wubx added the C-bug Category: something isn't working label Oct 28, 2024
@TCeason
Copy link
Collaborator

TCeason commented Oct 29, 2024

Can not reproduce in this version:
Query Version: v1.2.574-nightly-bd380eeeea(rust-1.81.0-nightly-2024-10-29T00:50:06.162961496Z)
Meta Version: v1.2.574-nightly-38cfe7686c-simd(1.81.0-nightly-2024-08-21T17:01:45.359166955Z)

Init env: Deploy a standalone mode Databend-query & Databend-meta

➜  databend git:(fix_16702) ✗ ls -lt .databend/logs
total 6236
-rw-r--r-- 1 eason eason   34289 Oct 29 08:53 databend-query-default.2024-10-29-08.0
-rw-r--r-- 1 eason eason       0 Oct 29 08:49 databend-meta-0@foo_cluster.2024-10-29-00
-rw-r--r-- 1 eason eason   28783 Oct 28 23:31 databend-query-default.2024-10-28-23.0
-rw-r--r-- 1 eason eason   54824 Oct 28 22:59 databend-query-default.2024-10-28-22.0
-rw-r--r-- 1 eason eason   54143 Oct 28 21:59 databend-query-default.2024-10-28-21.0
-rw-r--r-- 1 eason eason   62489 Oct 28 20:59 databend-query-default.2024-10-28-20.0
-rw-r--r-- 1 eason eason  600550 Oct 28 19:59 databend-query-default.2024-10-28-19.0
-rw-r--r-- 1 eason eason       0 Oct 28 19:40 databend-meta-0@foo_cluster.2024-10-28-11
-rw-r--r-- 1 eason eason     128 Oct 28 18:49 databend-meta-0@foo_cluster.2024-10-28-10
-rw-r--r-- 1 eason eason 1535059 Oct 28 18:49 databend-query-default.2024-10-28-18.0
-rw-r--r-- 1 eason eason 2272903 Oct 28 17:59 databend-query-default.2024-10-28-17.0
-rw-r--r-- 1 eason eason  155048 Oct 28 16:58 databend-query-default.2024-10-28-16.0
-rw-r--r-- 1 eason eason  133578 Oct 28 15:59 databend-query-default.2024-10-28-15.0
-rw-r--r-- 1 eason eason  198835 Oct 28 14:59 databend-query-default.2024-10-28-14.0
-rw-r--r-- 1 eason eason  501169 Oct 28 13:57 databend-query-default.2024-10-28-13.0
-rw-r--r-- 1 eason eason     128 Oct 28 13:29 databend-meta-0@foo_cluster.2024-10-28-05
-rw-r--r-- 1 eason eason  147411 Oct 28 12:59 databend-query-default.2024-10-28-12.0
-rw-r--r-- 1 eason eason  529614 Oct 28 11:57 databend-query-default.2024-10-28-11.0
-rw-r--r-- 1 eason eason   37021 Oct 28 10:59 databend-query-default.2024-10-28-10.0
-rw-r--r-- 1 eason eason       0 Oct 28 10:59 databend-meta-0@foo_cluster.2024-10-28-02

Modify code, set default limit = 1

diff --git a/src/common/tracing/src/config.rs b/src/common/tracing/src/config.rs
index 256700ff9b..f010fdceed 100644
--- a/src/common/tracing/src/config.rs
+++ b/src/common/tracing/src/config.rs
@@ -64,8 +64,8 @@ impl Display for FileConfig {
     fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
         write!(
             f,
-            "enabled={}, level={}, dir={}, format={}",
-            self.on, self.level, self.dir, self.format
+            "enabled={}, level={}, dir={}, format={}, limit={}, prefix_filter={}",
+            self.on, self.level, self.dir, self.format, self.limit, self.prefix_filter
         )
     }
 }
@@ -77,7 +77,7 @@ impl Default for FileConfig {
             level: "INFO".to_string(),
             dir: "./.databend/logs".to_string(),
             format: "json".to_string(),
-            limit: 48,
+            limit: 1,
             prefix_filter: "databend_,openraft".to_string(),
         }
     }
diff --git a/src/common/tracing/src/loggers.rs b/src/common/tracing/src/loggers.rs
index 6285a438fb..21240a23c7 100644
--- a/src/common/tracing/src/loggers.rs
+++ b/src/common/tracing/src/loggers.rs
@@ -33,6 +33,7 @@ pub(crate) fn new_rolling_file_appender(
     name: impl ToString,
     max_files: usize,
 ) -> (RollingFile, Box<dyn Send + Sync + 'static>) {
+    println!("max_files: {:?}", max_files);
     let rolling = RollingFileWriter::builder()
         .rotation(Rotation::Hourly)
         .filename_prefix(name.to_string())
diff --git a/src/query/config/src/config.rs b/src/query/config/src/config.rs
index 5cedd0c0d5..2753899878 100644
--- a/src/query/config/src/config.rs
+++ b/src/query/config/src/config.rs
@@ -2080,7 +2080,7 @@ pub struct FileLogConfig {
     pub file_format: String,
 
     /// Log file max
-    #[clap(long = "log-file-limit", value_name = "VALUE", default_value = "48")]
+    #[clap(long = "log-file-limit", value_name = "VALUE", default_value = "1")]
     #[serde(rename = "limit")]
     pub file_limit: usize,
 
@@ -2106,6 +2106,7 @@ impl TryInto<InnerFileLogConfig> for FileLogConfig {
     type Error = ErrorCode;
 
     fn try_into(self) -> Result<InnerFileLogConfig> {
+        println!("line 2109 {}", self.file_limit.clone());
         Ok(InnerFileLogConfig {
             on: self.file_on,
             level: self.file_level,

rebuild, start databend-query , log.file.limit is default value, not write in config.toml

# Usage:
# databend-query -c databend-query.toml

[query]
max_active_sessions = 256

# Internal flight rpc for cluster communication.
flight_api_address = "0.0.0.0:9091"

# Admin REST API.
admin_api_address = "0.0.0.0:8080"

# Metrics REST API.
metric_api_address = "0.0.0.0:7070"

# Query Handler: MySQL
mysql_handler_host = "0.0.0.0"
mysql_handler_port = 3307

# Query Handler: Clickhouse HTTP
clickhouse_http_handler_host = "0.0.0.0"
clickhouse_http_handler_port = 8124

# Query Handler: HTTP API
http_handler_host = "0.0.0.0"
http_handler_port = 8000

# Query Handler: Experimental Arrow Flight SQL API
flight_sql_handler_host = "0.0.0.0"
flight_sql_handler_port = 8900

tenant_id = "def"
cluster_id = "default"

#management_mode = true
table_engine_memory_enabled = true
enable_udf_server = true
udf_server_allow_list = ['http://0.0.0.0:8815']
#enable_meta_data_upgrade_json_to_pb_from_v307=true



#[[query.udfs]]
#name = "ping"
#definition = "CREATE FUNCTION ping(STRING) RETURNS STRING LANGUAGE python HANDLER = 'ping' ADDRESS = 'http://0.0.0.0:8815'"

[[query.users]]
name = "root"
auth_type = "no_password"

#[log.profile]
#on = true
#dir = "./.databend/profile_1"

[[query.users]]
name = "default"
auth_type = "no_password"

# [[query.users]]
# name = "databend"
# auth_type = "double_sha1_password"
# # echo -n "databend" | sha1sum | cut -d' ' -f1 | xxd -r -p | sha1sum
# auth_string = "3081f32caef285c232d066033c89a78d88a6d8a5"

# [[query.users]]
# name = "datafuselabs"
# auth_type = "sha256_password"
# #  echo -n "datafuselabs" | sha256sum
# auth_string = "6db1a2f5da402b43c066fcadcbf78f04260b3236d9035e44dd463f21e29e6f3b"


[log]

[log.file]
level = "INFO"
dir = ".databend/logs"

[meta]
# It is a list of `grpc_api_advertise_host:<grpc-api-port>` of databend-meta config
endpoints = ["0.0.0.0:9191"]
username = "root"
password = "root"
client_timeout_in_second = 60
auto_sync_interval = 60

# Storage config.
[storage]
# fs | s3 | azblob | obs | oss
type = "fs"

# Set a local folder to store your data.
# Comment out this block if you're NOT using local file system as storage.

# To use S3-compatible object storage, uncomment this block and set your values.
# [storage.s3]
# bucket = "<your-bucket-name>"
# endpoint_url = "<your-endpoint>"
# access_key_id = "<your-key-id>"
# secret_access_key = "<your-account-key>"
# enable_virtual_host_style = false

# To use Azure Blob storage, uncomment this block and set your values.
# [storage.azblob]
# endpoint_url = "https://<your-storage-account-name>.blob.core.windows.net"
# container = "<your-azure-storage-container-name>"
# account_name = "<your-storage-account-name>"
# account_key = "<your-account-key>"

# To use OBS object storage, uncomment this block and set your values.
# [storage.obs]
# bucket = "<your-bucket-name>"
# endpoint_url = "<your-endpoint>"
# access_key_id = "<your-key-id>"
# secret_access_key = "<your-account-key>"

# To use OSS object storage, uncomment this block and set your values.
# [storage.oss]
# bucket = "<your-bucket-name>"
# endpoint_url = "<your-endpoint>"
# access_key_id = "<your-key-id>"
# access_key_secret = "<your-account-key>"

# Cache config.
[cache]
# Type of storage to keep the table data cache
#
# available options: [none|disk]
# default is "none", which disable table data cache
# use "disk" to enabled disk cache
data_cache_storage = "none"

[background]
enable = true

[background.compaction]
enable_compaction = true
compact_mode = "interval"
target_tables = ["default.target1", "default.target2"]

Start

$ cargo build --bin databend-query && RUST_BACKTRACE=1 RUST_LOG=debug ./target/debug/databend-query -c test.toml --storage-allow-insecure # Version: v1.2.574-nightly-bd380eeeea(rust-1.81.0-nightly-2024-10-29T00:50:06.162961496Z)
$ ./target/debug/databend-meta --single --log-level=ERROR # v1.2.574-nightly-38cfe7686c-simd(1.81.0-nightly-2024-08-21T17:01:45.359166955Z)

Databend-query Print

line 2109 1
max_files: 1
Databend Query

Version: v1.2.574-nightly-bd380eeeea(rust-1.81.0-nightly-2024-10-29T00:50:06.162961496Z)

Logging:
    file: enabled=true, level=INFO, dir=.databend/logs, format=json, limit=1, prefix_filter=databend_,openraft
    stderr: enabled=false(To enable: LOG_STDERR_ON=true or RUST_LOG=info), level=INFO, format=text

Meta: connected to endpoints [
    "0.0.0.0:9191",
]

Memory:
    limit: unlimited
    allocator: jemalloc
    config: percpu_arena:percpu,oversize_threshold:0,background_thread:true,dirty_decay_ms:5000,muzzy_decay_ms:5000

Cluster: standalone

Storage: fs | root=_data
Disk cache:
    storage: none
    path: DiskCacheConfig { max_bytes: 21474836480, path: "./.databend/_cache", sync_data: true }
    reload policy: reset

Builtin users: root, default

Builtin UDFs: 

Admin
    listened at 0.0.0.0:8080
MySQL
    listened at 0.0.0.0:3307
    connect via: mysql -u${USER} -p${PASSWORD} -h0.0.0.0 -P3307
Clickhouse(http)
    listened at 0.0.0.0:8124
    usage:  echo 'create table test(foo string)' | curl -u${USER} -p${PASSWORD}: '0.0.0.0:8124' --data-binary  @-
echo '{"foo": "bar"}' | curl -u${USER} -p${PASSWORD}: '0.0.0.0:8124/?query=INSERT%20INTO%20test%20FORMAT%20JSONEachRow' --data-binary @-
Databend HTTP
    listened at 0.0.0.0:8000
    usage:  curl -u${USER} -p${PASSWORD}: --request POST '0.0.0.0:8000/v1/query/' --header 'Content-Type: application/json' --data-raw '{"sql": "SELECT avg(number) FROM numbers(100000000)"}'

Start background service

The query log file num is 1. databend-query-default.2024-10-29-09.0

➜  databend git:(fix_16702) ✗ ls -lt .databend/logs
total 20
-rw-r--r-- 1 eason eason 12086 Oct 29 09:16 databend-query-default.2024-10-29-09.0
-rw-r--r-- 1 eason eason     0 Oct 29 08:49 databend-meta-0@foo_cluster.2024-10-29-00
-rw-r--r-- 1 eason eason     0 Oct 28 19:40 databend-meta-0@foo_cluster.2024-10-28-11
-rw-r--r-- 1 eason eason   128 Oct 28 18:49 databend-meta-0@foo_cluster.2024-10-28-10
-rw-r--r-- 1 eason eason   128 Oct 28 13:29 databend-meta-0@foo_cluster.2024-10-28-05
-rw-r--r-- 1 eason eason     0 Oct 28 10:59 databend-meta-0@foo_cluster.2024-10-28-02

Wait 1 hour. The query log file num is still 1. databend-query-default.2024-10-29-10.0

➜  databend git:(fix_16702) ✗ ls -lt .databend/logs
total 200
-rw-r--r-- 1 eason eason 112671 Oct 29 10:00 databend-query-default.2024-10-29-10.0
-rw-r--r-- 1 eason eason      0 Oct 29 08:49 databend-meta-0@foo_cluster.2024-10-29-00
-rw-r--r-- 1 eason eason      0 Oct 28 19:40 databend-meta-0@foo_cluster.2024-10-28-11
-rw-r--r-- 1 eason eason    128 Oct 28 18:49 databend-meta-0@foo_cluster.2024-10-28-10
-rw-r--r-- 1 eason eason    128 Oct 28 13:29 databend-meta-0@foo_cluster.2024-10-28-05
-rw-r--r-- 1 eason eason      0 Oct 28 10:59 databend-meta-0@foo_cluster.2024-10-28-02

➜  databend git:(fix_16702) ✗ head .databend/logs/databend-query-default.2024-10-29-10.0
{"timestamp":"2024-10-29T10:00:20.764498+08:00","level":"WARN","fields":{"message":"distinct endpoints small than majority of meta cluster nodes 0<1, endpoints: [\"\"]"}}
{"timestamp":"2024-10-29T10:00:20.766108+08:00","level":"WARN","fields":{"message":"distinct endpoints small than majority of meta cluster nodes 0<1, endpoints: [\"\"]"}}
{"timestamp":"2024-10-29T10:00:20.795175+08:00","level":"WARN","fields":{"message":"distinct endpoints small than majority of meta cluster nodes 0<1, endpoints: [\"\"]"}}
{"timestamp":"2024-10-29T10:00:20.796783+08:00","level":"WARN","fields":{"message":"distinct endpoints small than majority of meta cluster nodes 0<1, endpoints: [\"\"]"}}
{"timestamp":"2024-10-29T10:00:32.963395+08:00","level":"INFO","query_id":"ca86e6ec-f56a-4ffc-a2d0-d1fe3d3f651a","fields":{"message":"http query new request(from bendsql/0.18.3-5010f07): HttpQueryRequest { session_id: None, session: Some(HttpSessionConf { database: None, role: None, secondary_roles: None, keep_server_session_secs: None, settings: Some({}), txn_state: None, need_sticky: false, need_refresh: false, last_server_info: None, last_query_ids: [], internal: None }), sql: \"SELECT version()\", pagination: PaginationConf { wait_time_secs: 10, max_rows_in_buffer: 5000000, max_rows_per_page: 10000 }, string_fields: true, stage_attachment: None }"}}


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants