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

feat: support pg service & pg meta backend in risedev using docker #16662

Merged
merged 6 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
98 changes: 98 additions & 0 deletions risedev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand All @@ -119,6 +120,7 @@ profile:
- use: etcd
- use: meta-node
user-managed: true
meta-backend: etcd
- use: compute-node
user-managed: true
- use: frontend
Expand All @@ -136,6 +138,7 @@ profile:
- use: etcd
- use: meta-node
user-managed: true
meta-backend: etcd
- use: compute-node
user-managed: true
- use: frontend
Expand All @@ -149,6 +152,7 @@ profile:
- use: etcd
- use: meta-node
user-managed: true
meta-backend: etcd
- use: compute-node
user-managed: true
- use: frontend
Expand Down Expand Up @@ -253,6 +257,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand Down Expand Up @@ -286,6 +291,7 @@ profile:
port: 5690
dashboard-port: 5691
exporter-port: 1250
meta-backend: etcd
- use: meta-node
port: 15690
dashboard-port: 15691
Expand Down Expand Up @@ -333,6 +339,7 @@ profile:
port: 5690
dashboard-port: 5691
exporter-port: 1250
meta-backend: etcd
- use: meta-node
port: 15690
dashboard-port: 15691
Expand All @@ -353,6 +360,7 @@ profile:
port: 5690
dashboard-port: 5691
exporter-port: 1250
meta-backend: sqlite
- use: compactor
- use: compute-node
- use: frontend
Expand All @@ -366,6 +374,40 @@ profile:
port: 5690
dashboard-port: 5691
exporter-port: 1250
meta-backend: sqlite
- use: compactor
- use: compute-node
- use: frontend

meta-1cn-1fe-pg-backend:
steps:
- use: minio
- use: postgres
port: 8432
user: postgres
database: metadata
- use: meta-node
port: 5690
dashboard-port: 5691
exporter-port: 1250
meta-backend: postgres
- use: compactor
- use: compute-node
- use: frontend

meta-1cn-1fe-pg-backend-with-recovery:
config-path: src/config/ci-recovery.toml
steps:
- use: minio
- use: postgres
port: 8432
user: postgres
database: metadata
- use: meta-node
port: 5690
dashboard-port: 5691
exporter-port: 1250
meta-backend: postgres
- use: compactor
- use: compute-node
- use: frontend
Expand All @@ -392,6 +434,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
parallelism: 8
- use: frontend
Expand Down Expand Up @@ -550,6 +593,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
enable-tiered-cache: true
- use: frontend
Expand All @@ -562,6 +606,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand All @@ -584,6 +629,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand All @@ -610,6 +656,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand All @@ -634,6 +681,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand All @@ -658,6 +706,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand Down Expand Up @@ -717,6 +766,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: opendal
engine: fs
bucket: "/tmp/rw_ci"
Expand Down Expand Up @@ -750,6 +800,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand Down Expand Up @@ -801,6 +852,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
enable-tiered-cache: true
- use: frontend
Expand All @@ -817,6 +869,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
enable-tiered-cache: true
- use: frontend
Expand All @@ -841,6 +894,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
enable-tiered-cache: true
- use: frontend
Expand All @@ -854,6 +908,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
enable-tiered-cache: true
total-memory-bytes: 17179869184
Expand All @@ -866,6 +921,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
enable-tiered-cache: true
- use: frontend
Expand All @@ -878,6 +934,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand All @@ -899,6 +956,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
enable-tiered-cache: true
- use: frontend
Expand All @@ -912,6 +970,7 @@ profile:
- use: etcd
- use: minio
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand All @@ -928,6 +987,7 @@ profile:
- use: sqlite
- use: minio
- use: meta-node
meta-backend: sqlite
- use: compute-node
- use: frontend
- use: compactor
Expand Down Expand Up @@ -978,6 +1038,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand All @@ -989,6 +1050,7 @@ profile:
bucket: renjie-iceberg-bench
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand All @@ -1001,6 +1063,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand Down Expand Up @@ -1161,12 +1224,18 @@ template:
# If `user-managed` is true, this service will be started by user with the above config
user-managed: false

# meta backend type, requires extra config for provided backend
meta-backend: "memory"

# Etcd backend config
provide-etcd-backend: "etcd*"

# Sqlite backend config
provide-sqlite-backend: "sqlite*"

# Postgres backend config
provide-postgres-backend: "postgres*"

# Prometheus nodes used by dashboard service
provide-prometheus: "prometheus*"

Expand Down Expand Up @@ -1444,3 +1513,32 @@ template:
# If `user-managed` is true, user is responsible for starting the service
# to serve at the above address and port in any way they see fit.
user-managed: false

# PostgreSQL service backed by docker.
postgres:
# Id to be picked-up by services
id: postgres-${port}

# address of pg
address: "127.0.0.1"

# listen port of pg
port: 8432

# Note:
# - This will be used to initialize the PostgreSQL instance if it's fresh.
# - In user-managed mode, these configs are not validated by risedev.
# They are passed as-is to risedev-env default user for PostgreSQL operations.
yezizp2012 marked this conversation as resolved.
Show resolved Hide resolved
user: postgres
password: ""
database: "postgres"

# The docker image. Can be overridden to use a different version.
image: "postgres:15-alpine"

# If set to true, data will be persisted at data/{id}.
persist-data: true

# If `user-managed` is true, user is responsible for starting the service
# to serve at the above address and port in any way they see fit.
user-managed: false
2 changes: 1 addition & 1 deletion src/cmd_all/src/single_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub fn map_single_node_opts_to_standalone_opts(opts: SingleNodeOpts) -> ParsedSt
std::fs::create_dir_all(&meta_store_dir).unwrap();
let meta_store_endpoint =
format!("sqlite://{}/single_node.db?mode=rwc", &meta_store_dir);
meta_opts.sql_endpoint = Some(meta_store_endpoint);
meta_opts.sql_endpoint = Some(meta_store_endpoint.into());
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/meta/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub struct MetaNodeOpts {

/// Endpoint of the SQL service, make it non-option when SQL service is required.
#[clap(long, hide = true, env = "RW_SQL_ENDPOINT")]
pub sql_endpoint: Option<String>,
pub sql_endpoint: Option<Secret<String>>,
yezizp2012 marked this conversation as resolved.
Show resolved Hide resolved

/// The HTTP REST-API address of the Prometheus instance associated to this cluster.
/// This address is used to serve `PromQL` queries to Prometheus.
Expand Down Expand Up @@ -221,7 +221,11 @@ pub fn start(opts: MetaNodeOpts) -> Pin<Box<dyn Future<Output = ()> + Send>> {
},
MetaBackend::Mem => MetaStoreBackend::Mem,
MetaBackend::Sql => MetaStoreBackend::Sql {
endpoint: opts.sql_endpoint.expect("sql endpoint is required"),
endpoint: opts
.sql_endpoint
.expect("sql endpoint is required")
.expose_secret()
.to_string(),
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/risedevtool/src/bin/risedev-compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ fn main() -> Result<()> {
volumes.insert(c.id.clone(), ComposeVolume::default());
(c.address.clone(), c.compose(&compose_config)?)
}
ServiceConfig::Redis(_) | ServiceConfig::MySql(_) => {
ServiceConfig::Redis(_) | ServiceConfig::MySql(_) | ServiceConfig::Postgres(_) => {
return Err(anyhow!("not supported"))
}
};
Expand Down
15 changes: 13 additions & 2 deletions src/risedevtool/src/bin/risedev-dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ use risedev::util::{complete_spin, fail_spin};
use risedev::{
generate_risedev_env, preflight_check, CompactorService, ComputeNodeService, ConfigExpander,
ConfigureTmuxTask, DummyService, EnsureStopService, ExecuteContext, FrontendService,
GrafanaService, KafkaService, MetaNodeService, MinioService, MySqlService, PrometheusService,
PubsubService, RedisService, ServiceConfig, SqliteConfig, Task, TempoService, RISEDEV_NAME,
GrafanaService, KafkaService, MetaNodeService, MinioService, MySqlService, PostgresService,
PrometheusService, PubsubService, RedisService, ServiceConfig, SqliteConfig, Task,
TempoService, RISEDEV_NAME,
};
use tempfile::tempdir;
use thiserror_ext::AsReport;
Expand Down Expand Up @@ -314,6 +315,16 @@ fn task_main(
ctx.pb
.set_message(format!("mysql {}:{}", c.address, c.port));
}
ServiceConfig::Postgres(c) => {
let mut ctx =
ExecuteContext::new(&mut logger, manager.new_progress(), status_dir.clone());
PostgresService::new(c.clone()).execute(&mut ctx)?;
let mut task =
risedev::ConfigureTcpNodeTask::new(c.address.clone(), c.port, c.user_managed)?;
task.execute(&mut ctx)?;
ctx.pb
.set_message(format!("postgres {}:{}", c.address, c.port));
}
}

let service_id = service.id().to_string();
Expand Down