mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-27 08:29:59 +00:00
fix(sqlness): sqlness isolation (#4780)
* fix: isolate logs * fix: copy cases * fix: clippy
This commit is contained in:
@@ -6,11 +6,11 @@ INSERT INTO demo(host, cpu, memory, ts) values ('host1', 66.6, 1024, 16552765570
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
COPY DATABASE public TO '/tmp/demo/export/parquet/' WITH (FORMAT="parquet");
|
||||
COPY DATABASE public TO '${SQLNESS_HOME}/demo/export/parquet/' WITH (FORMAT="parquet");
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
COPY DATABASE public TO '/tmp/demo/export/parquet_range/' WITH (FORMAT="parquet", start_time='2022-06-15 07:02:37.000Z', end_time='2022-06-15 07:02:37.1Z');
|
||||
COPY DATABASE public TO '${SQLNESS_HOME}/demo/export/parquet_range/' WITH (FORMAT="parquet", start_time='2022-06-15 07:02:37.000Z', end_time='2022-06-15 07:02:37.1Z');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
@@ -23,7 +23,7 @@ SELECT * FROM demo ORDER BY ts;
|
||||
++
|
||||
++
|
||||
|
||||
COPY DATABASE public FROM '/tmp/demo/export/parquet/';
|
||||
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet/';
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
@@ -40,7 +40,7 @@ DELETE FROM demo;
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
COPY DATABASE public FROM '/tmp/demo/export/parquet_range/';
|
||||
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet_range/';
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
@@ -56,7 +56,7 @@ DELETE FROM demo;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
COPY DATABASE public FROM '/tmp/demo/export/parquet_range/' LIMIT 2;
|
||||
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet_range/' LIMIT 2;
|
||||
|
||||
Error: 2000(InvalidSyntax), Invalid SQL, error: limit is not supported
|
||||
|
||||
|
||||
@@ -2,26 +2,26 @@ CREATE TABLE demo(host string, cpu double, memory double, ts TIMESTAMP time inde
|
||||
|
||||
INSERT INTO demo(host, cpu, memory, ts) values ('host1', 66.6, 1024, 1655276557000), ('host2', 88.8, 333.3, 1655276558000);
|
||||
|
||||
COPY DATABASE public TO '/tmp/demo/export/parquet/' WITH (FORMAT="parquet");
|
||||
COPY DATABASE public TO '${SQLNESS_HOME}/demo/export/parquet/' WITH (FORMAT="parquet");
|
||||
|
||||
COPY DATABASE public TO '/tmp/demo/export/parquet_range/' WITH (FORMAT="parquet", start_time='2022-06-15 07:02:37.000Z', end_time='2022-06-15 07:02:37.1Z');
|
||||
COPY DATABASE public TO '${SQLNESS_HOME}/demo/export/parquet_range/' WITH (FORMAT="parquet", start_time='2022-06-15 07:02:37.000Z', end_time='2022-06-15 07:02:37.1Z');
|
||||
|
||||
DELETE FROM demo;
|
||||
|
||||
SELECT * FROM demo ORDER BY ts;
|
||||
|
||||
COPY DATABASE public FROM '/tmp/demo/export/parquet/';
|
||||
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet/';
|
||||
|
||||
SELECT * FROM demo ORDER BY ts;
|
||||
|
||||
DELETE FROM demo;
|
||||
|
||||
COPY DATABASE public FROM '/tmp/demo/export/parquet_range/';
|
||||
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet_range/';
|
||||
|
||||
SELECT * FROM demo ORDER BY ts;
|
||||
|
||||
DELETE FROM demo;
|
||||
|
||||
COPY DATABASE public FROM '/tmp/demo/export/parquet_range/' LIMIT 2;
|
||||
COPY DATABASE public FROM '${SQLNESS_HOME}/demo/export/parquet_range/' LIMIT 2;
|
||||
|
||||
DROP TABLE demo;
|
||||
|
||||
@@ -11,7 +11,7 @@ values
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
Copy demo TO '/tmp/demo/export/csv/demo.csv' with (format='csv');
|
||||
Copy demo TO '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv');
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
@@ -19,7 +19,7 @@ CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
Copy with_filename FROM '/tmp/demo/export/csv/demo.csv' with (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
@@ -36,7 +36,7 @@ CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
Copy with_path FROM '/tmp/demo/export/csv/' with (format='csv', start_time='2023-06-15 07:02:37');
|
||||
Copy with_path FROM '${SQLNESS_HOME}/demo/export/csv/' with (format='csv', start_time='2023-06-15 07:02:37');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
@@ -52,7 +52,7 @@ CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp t
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
Copy with_pattern FROM '/tmp/demo/export/csv/' WITH (pattern = 'demo.*', format='csv', end_time='2025-06-15 07:02:39');
|
||||
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/csv/' WITH (pattern = 'demo.*', format='csv', end_time='2025-06-15 07:02:39');
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
|
||||
@@ -7,23 +7,23 @@ values
|
||||
('host2', 88.8, 333.3, 1655276558000),
|
||||
('host3', 99.9, 444.4, 1722077263000);
|
||||
|
||||
Copy demo TO '/tmp/demo/export/csv/demo.csv' with (format='csv');
|
||||
Copy demo TO '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv');
|
||||
|
||||
CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Copy with_filename FROM '/tmp/demo/export/csv/demo.csv' with (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
|
||||
select * from with_filename order by ts;
|
||||
|
||||
CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Copy with_path FROM '/tmp/demo/export/csv/' with (format='csv', start_time='2023-06-15 07:02:37');
|
||||
Copy with_path FROM '${SQLNESS_HOME}/demo/export/csv/' with (format='csv', start_time='2023-06-15 07:02:37');
|
||||
|
||||
select * from with_path order by ts;
|
||||
|
||||
CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Copy with_pattern FROM '/tmp/demo/export/csv/' WITH (pattern = 'demo.*', format='csv', end_time='2025-06-15 07:02:39');
|
||||
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/csv/' WITH (pattern = 'demo.*', format='csv', end_time='2025-06-15 07:02:39');
|
||||
|
||||
select * from with_pattern order by ts;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ values
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
Copy demo TO '/tmp/demo/export/json/demo.json' with (format='json');
|
||||
Copy demo TO '${SQLNESS_HOME}/demo/export/json/demo.json' with (format='json');
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
@@ -19,7 +19,7 @@ CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
Copy with_filename FROM '/tmp/demo/export/json/demo.json' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/json/demo.json' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
@@ -36,7 +36,7 @@ CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
Copy with_path FROM '/tmp/demo/export/json/' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
Copy with_path FROM '${SQLNESS_HOME}/demo/export/json/' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
@@ -53,7 +53,7 @@ CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp t
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
Copy with_pattern FROM '/tmp/demo/export/json/' WITH (pattern = 'demo.*',format='json', end_time='2022-06-15 07:02:39');
|
||||
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/json/' WITH (pattern = 'demo.*',format='json', end_time='2022-06-15 07:02:39');
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
|
||||
@@ -7,23 +7,23 @@ values
|
||||
('host2', 88.8, 333.3, 1655276558000),
|
||||
('host3', 99.9, 444.4, 1722077263000);
|
||||
|
||||
Copy demo TO '/tmp/demo/export/json/demo.json' with (format='json');
|
||||
Copy demo TO '${SQLNESS_HOME}/demo/export/json/demo.json' with (format='json');
|
||||
|
||||
CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Copy with_filename FROM '/tmp/demo/export/json/demo.json' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/json/demo.json' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
|
||||
select * from with_filename order by ts;
|
||||
|
||||
CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Copy with_path FROM '/tmp/demo/export/json/' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
Copy with_path FROM '${SQLNESS_HOME}/demo/export/json/' with (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
|
||||
select * from with_path order by ts;
|
||||
|
||||
CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Copy with_pattern FROM '/tmp/demo/export/json/' WITH (pattern = 'demo.*',format='json', end_time='2022-06-15 07:02:39');
|
||||
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/json/' WITH (pattern = 'demo.*',format='json', end_time='2022-06-15 07:02:39');
|
||||
|
||||
select * from with_pattern order by ts;
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ values
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
Copy demo TO '/tmp/demo/export/parquet_files/demo.parquet';
|
||||
Copy demo TO '${SQLNESS_HOME}/demo/export/parquet_files/demo.parquet';
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
Copy demo_2 TO '/tmp/demo/export/parquet_files/demo_2.parquet';
|
||||
Copy demo_2 TO '${SQLNESS_HOME}/demo/export/parquet_files/demo_2.parquet';
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
@@ -36,7 +36,7 @@ CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
Copy with_filename FROM '/tmp/demo/export/parquet_files/demo.parquet' with (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/parquet_files/demo.parquet' with (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
@@ -53,7 +53,7 @@ CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
Copy with_path FROM '/tmp/demo/export/parquet_files/';
|
||||
Copy with_path FROM '${SQLNESS_HOME}/demo/export/parquet_files/';
|
||||
|
||||
Affected Rows: 6
|
||||
|
||||
@@ -74,7 +74,7 @@ CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp t
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
Copy with_pattern FROM '/tmp/demo/export/parquet_files/' WITH (PATTERN = 'demo.*', start_time='2022-06-15 07:02:39');
|
||||
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/parquet_files/' WITH (PATTERN = 'demo.*', start_time='2022-06-15 07:02:39');
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
@@ -91,7 +91,7 @@ CREATE TABLE without_limit_rows(host string, cpu double, memory double, ts times
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
Copy without_limit_rows FROM '/tmp/demo/export/parquet_files/';
|
||||
Copy without_limit_rows FROM '${SQLNESS_HOME}/demo/export/parquet_files/';
|
||||
|
||||
Affected Rows: 6
|
||||
|
||||
@@ -107,7 +107,7 @@ CREATE TABLE with_limit_rows_segment(host string, cpu double, memory double, ts
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
Copy with_limit_rows_segment FROM '/tmp/demo/export/parquet_files/' LIMIT 3;
|
||||
Copy with_limit_rows_segment FROM '${SQLNESS_HOME}/demo/export/parquet_files/' LIMIT 3;
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
@@ -119,9 +119,9 @@ select count(*) from with_limit_rows_segment;
|
||||
| 3 |
|
||||
+----------+
|
||||
|
||||
Copy with_limit_rows_segment FROM '/tmp/demo/export/parquet_files/' LIMIT hello;
|
||||
Copy with_limit_rows_segment FROM '${SQLNESS_HOME}/demo/export/parquet_files/' LIMIT hello;
|
||||
|
||||
Error: 2000(InvalidSyntax), Unexpected token while parsing SQL statement, expected: 'the number of maximum rows', found: ;: sql parser error: Expected literal int, found: hello at Line: 1, Column 75
|
||||
Error: 2000(InvalidSyntax), Unexpected token while parsing SQL statement, expected: 'the number of maximum rows', found: ;: sql parser error: Expected literal int, found: hello at Line: 1, Column 86
|
||||
|
||||
drop table demo;
|
||||
|
||||
|
||||
@@ -16,41 +16,41 @@ values
|
||||
('host5', 99.9, 444.4, 1655276556000),
|
||||
('host6', 222.2, 555.5, 1722077264000);
|
||||
|
||||
Copy demo TO '/tmp/demo/export/parquet_files/demo.parquet';
|
||||
Copy demo TO '${SQLNESS_HOME}/demo/export/parquet_files/demo.parquet';
|
||||
|
||||
Copy demo_2 TO '/tmp/demo/export/parquet_files/demo_2.parquet';
|
||||
Copy demo_2 TO '${SQLNESS_HOME}/demo/export/parquet_files/demo_2.parquet';
|
||||
|
||||
CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Copy with_filename FROM '/tmp/demo/export/parquet_files/demo.parquet' with (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
Copy with_filename FROM '${SQLNESS_HOME}/demo/export/parquet_files/demo.parquet' with (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39');
|
||||
|
||||
select * from with_filename order by ts;
|
||||
|
||||
CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Copy with_path FROM '/tmp/demo/export/parquet_files/';
|
||||
Copy with_path FROM '${SQLNESS_HOME}/demo/export/parquet_files/';
|
||||
|
||||
select * from with_path order by ts;
|
||||
|
||||
CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Copy with_pattern FROM '/tmp/demo/export/parquet_files/' WITH (PATTERN = 'demo.*', start_time='2022-06-15 07:02:39');
|
||||
Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/parquet_files/' WITH (PATTERN = 'demo.*', start_time='2022-06-15 07:02:39');
|
||||
|
||||
select * from with_pattern order by ts;
|
||||
|
||||
CREATE TABLE without_limit_rows(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Copy without_limit_rows FROM '/tmp/demo/export/parquet_files/';
|
||||
Copy without_limit_rows FROM '${SQLNESS_HOME}/demo/export/parquet_files/';
|
||||
|
||||
select count(*) from without_limit_rows;
|
||||
|
||||
CREATE TABLE with_limit_rows_segment(host string, cpu double, memory double, ts timestamp time index);
|
||||
|
||||
Copy with_limit_rows_segment FROM '/tmp/demo/export/parquet_files/' LIMIT 3;
|
||||
Copy with_limit_rows_segment FROM '${SQLNESS_HOME}/demo/export/parquet_files/' LIMIT 3;
|
||||
|
||||
select count(*) from with_limit_rows_segment;
|
||||
|
||||
Copy with_limit_rows_segment FROM '/tmp/demo/export/parquet_files/' LIMIT hello;
|
||||
Copy with_limit_rows_segment FROM '${SQLNESS_HOME}/demo/export/parquet_files/' LIMIT hello;
|
||||
|
||||
drop table demo;
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@ insert into demo(host, cpu, memory, ts) values ('host1', 66.6, 1024, 16552765570
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
COPY demo TO '/tmp/export/demo.parquet' WITH (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
COPY demo TO '${SQLNESS_HOME}/export/demo.parquet' WITH (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
COPY demo TO '/tmp/export/demo.csv' WITH (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
COPY demo TO '${SQLNESS_HOME}/export/demo.csv' WITH (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
COPY demo TO '/tmp/export/demo.json' WITH (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
COPY demo TO '${SQLNESS_HOME}/export/demo.json' WITH (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ CREATE TABLE demo(host string, cpu DOUBLE, memory DOUBLE, ts TIMESTAMP TIME INDE
|
||||
|
||||
insert into demo(host, cpu, memory, ts) values ('host1', 66.6, 1024, 1655276557000), ('host2', 88.8, 333.3, 1655276558000);
|
||||
|
||||
COPY demo TO '/tmp/export/demo.parquet' WITH (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
COPY demo TO '${SQLNESS_HOME}/export/demo.parquet' WITH (start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
|
||||
COPY demo TO '/tmp/export/demo.csv' WITH (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
COPY demo TO '${SQLNESS_HOME}/export/demo.csv' WITH (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
|
||||
COPY demo TO '/tmp/export/demo.json' WITH (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
COPY demo TO '${SQLNESS_HOME}/export/demo.json' WITH (format='json', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:38');
|
||||
|
||||
drop table demo;
|
||||
|
||||
@@ -54,7 +54,7 @@ pub enum WalConfig {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Env {
|
||||
data_home: PathBuf,
|
||||
sqlness_home: PathBuf,
|
||||
server_addr: Option<String>,
|
||||
wal: WalConfig,
|
||||
|
||||
@@ -69,6 +69,7 @@ impl EnvController for Env {
|
||||
type DB = GreptimeDB;
|
||||
|
||||
async fn start(&self, mode: &str, _config: Option<&Path>) -> Self::DB {
|
||||
std::env::set_var("SQLNESS_HOME", self.sqlness_home.display().to_string());
|
||||
match mode {
|
||||
"standalone" => self.start_standalone().await,
|
||||
"distributed" => self.start_distributed().await,
|
||||
@@ -90,7 +91,7 @@ impl Env {
|
||||
bins_dir: Option<PathBuf>,
|
||||
) -> Self {
|
||||
Self {
|
||||
data_home,
|
||||
sqlness_home: data_home,
|
||||
server_addr,
|
||||
wal,
|
||||
bins_dir: Arc::new(Mutex::new(bins_dir)),
|
||||
@@ -204,26 +205,30 @@ impl Env {
|
||||
"standalone" => "greptime-sqlness-standalone.log".to_string(),
|
||||
_ => panic!("Unexpected subcommand: {subcommand}"),
|
||||
};
|
||||
let log_file_name = self.data_home.join(log_file_name).display().to_string();
|
||||
let stdout_file_name = self.sqlness_home.join(log_file_name).display().to_string();
|
||||
|
||||
println!("{subcommand} log file at {log_file_name}");
|
||||
println!("{subcommand} log file at {stdout_file_name}");
|
||||
|
||||
let log_file = OpenOptions::new()
|
||||
let stdout_file = OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.truncate(truncate_log)
|
||||
.append(!truncate_log)
|
||||
.open(log_file_name)
|
||||
.open(stdout_file_name)
|
||||
.unwrap();
|
||||
|
||||
let (args, check_ip_addr) = match subcommand {
|
||||
"datanode" => self.datanode_start_args(db_ctx),
|
||||
"flownode" => self.flownode_start_args(db_ctx),
|
||||
"flownode" => self.flownode_start_args(db_ctx, &self.sqlness_home),
|
||||
"standalone" => {
|
||||
let args = vec![
|
||||
DEFAULT_LOG_LEVEL.to_string(),
|
||||
subcommand.to_string(),
|
||||
"start".to_string(),
|
||||
format!(
|
||||
"--log-dir={}/greptimedb-flownode/logs",
|
||||
self.sqlness_home.display()
|
||||
),
|
||||
"-c".to_string(),
|
||||
self.generate_config_file(subcommand, db_ctx),
|
||||
"--http-addr=127.0.0.1:5002".to_string(),
|
||||
@@ -237,6 +242,10 @@ impl Env {
|
||||
"start".to_string(),
|
||||
"--metasrv-addrs=127.0.0.1:3002".to_string(),
|
||||
"--http-addr=127.0.0.1:5003".to_string(),
|
||||
format!(
|
||||
"--log-dir={}/greptimedb-frontend/logs",
|
||||
self.sqlness_home.display()
|
||||
),
|
||||
];
|
||||
(args, SERVER_ADDR.to_string())
|
||||
}
|
||||
@@ -250,6 +259,10 @@ impl Env {
|
||||
"--enable-region-failover".to_string(),
|
||||
"false".to_string(),
|
||||
"--http-addr=127.0.0.1:5002".to_string(),
|
||||
format!(
|
||||
"--log-dir={}/greptimedb-metasrv/logs",
|
||||
self.sqlness_home.display()
|
||||
),
|
||||
"-c".to_string(),
|
||||
self.generate_config_file(subcommand, db_ctx),
|
||||
];
|
||||
@@ -278,7 +291,7 @@ impl Env {
|
||||
.current_dir(bins_dir)
|
||||
.env("TZ", "UTC")
|
||||
.args(args)
|
||||
.stdout(log_file)
|
||||
.stdout(stdout_file)
|
||||
.spawn()
|
||||
.unwrap_or_else(|error| {
|
||||
panic!("Failed to start the DB with subcommand {subcommand},Error: {error}")
|
||||
@@ -296,7 +309,7 @@ impl Env {
|
||||
let id = db_ctx.datanode_id();
|
||||
|
||||
let data_home = self
|
||||
.data_home
|
||||
.sqlness_home
|
||||
.join(format!("greptimedb_datanode_{}_{id}", db_ctx.time));
|
||||
|
||||
let subcommand = "datanode";
|
||||
@@ -308,6 +321,7 @@ impl Env {
|
||||
args.push(format!("--rpc-addr=127.0.0.1:410{id}"));
|
||||
args.push(format!("--http-addr=127.0.0.1:430{id}"));
|
||||
args.push(format!("--data-home={}", data_home.display()));
|
||||
args.push(format!("--log-dir={}/logs", data_home.display()));
|
||||
args.push(format!("--node-id={id}"));
|
||||
args.push("-c".to_string());
|
||||
args.push(self.generate_config_file(subcommand, db_ctx));
|
||||
@@ -315,7 +329,11 @@ impl Env {
|
||||
(args, format!("127.0.0.1:410{id}"))
|
||||
}
|
||||
|
||||
fn flownode_start_args(&self, _db_ctx: &GreptimeDBContext) -> (Vec<String>, String) {
|
||||
fn flownode_start_args(
|
||||
&self,
|
||||
_db_ctx: &GreptimeDBContext,
|
||||
sqlness_home: &Path,
|
||||
) -> (Vec<String>, String) {
|
||||
let id = 0;
|
||||
|
||||
let subcommand = "flownode";
|
||||
@@ -326,6 +344,10 @@ impl Env {
|
||||
];
|
||||
args.push(format!("--rpc-addr=127.0.0.1:680{id}"));
|
||||
args.push(format!("--node-id={id}"));
|
||||
args.push(format!(
|
||||
"--log-dir={}/greptimedb-flownode/logs",
|
||||
sqlness_home.display()
|
||||
));
|
||||
args.push("--metasrv-addrs=127.0.0.1:3002".to_string());
|
||||
(args, format!("127.0.0.1:680{id}"))
|
||||
}
|
||||
@@ -387,7 +409,7 @@ impl Env {
|
||||
kafka_wal_broker_endpoints: String,
|
||||
}
|
||||
|
||||
let data_home = self.data_home.join(format!("greptimedb-{subcommand}"));
|
||||
let data_home = self.sqlness_home.join(format!("greptimedb-{subcommand}"));
|
||||
std::fs::create_dir_all(data_home.as_path()).unwrap();
|
||||
|
||||
let wal_dir = data_home.join("wal").display().to_string();
|
||||
|
||||
@@ -82,7 +82,7 @@ async fn main() {
|
||||
.prefix("sqlness")
|
||||
.tempdir()
|
||||
.unwrap();
|
||||
let data_home = temp_dir.into_path();
|
||||
let sqlness_home = temp_dir.into_path();
|
||||
|
||||
let config = ConfigBuilder::default()
|
||||
.case_dir(util::get_case_dir(args.case_dir))
|
||||
@@ -107,13 +107,13 @@ async fn main() {
|
||||
|
||||
let runner = Runner::new(
|
||||
config,
|
||||
Env::new(data_home.clone(), args.server_addr, wal, args.bins_dir),
|
||||
Env::new(sqlness_home.clone(), args.server_addr, wal, args.bins_dir),
|
||||
);
|
||||
runner.run().await.unwrap();
|
||||
|
||||
// clean up and exit
|
||||
if !args.preserve_state {
|
||||
println!("Removing state in {:?}", data_home);
|
||||
tokio::fs::remove_dir_all(data_home).await.unwrap();
|
||||
println!("Removing state in {:?}", sqlness_home);
|
||||
tokio::fs::remove_dir_all(sqlness_home).await.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user