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) #16804

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions risedev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand All @@ -124,6 +125,7 @@ profile:
- use: etcd
- use: meta-node
user-managed: true
meta-backend: etcd
- use: compute-node
user-managed: true
- use: frontend
Expand All @@ -143,6 +145,7 @@ profile:
- use: etcd
- use: meta-node
user-managed: true
meta-backend: etcd
- use: compute-node
user-managed: true
- use: frontend
Expand All @@ -156,6 +159,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 @@ -260,6 +264,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand Down Expand Up @@ -295,6 +300,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 @@ -342,6 +348,7 @@ profile:
port: 5690
dashboard-port: 5691
exporter-port: 1250
meta-backend: etcd
- use: meta-node
port: 15690
dashboard-port: 15691
Expand All @@ -362,6 +369,7 @@ profile:
port: 5690
dashboard-port: 5691
exporter-port: 1250
meta-backend: sqlite
- use: compactor
- use: compute-node
- use: frontend
Expand All @@ -375,6 +383,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 @@ -401,6 +443,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
parallelism: 8
- use: frontend
Expand Down Expand Up @@ -561,6 +604,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 @@ -573,6 +617,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand All @@ -595,6 +640,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand All @@ -621,6 +667,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand All @@ -645,6 +692,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand All @@ -669,6 +717,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 @@ -728,6 +777,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 @@ -761,6 +811,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 @@ -812,6 +863,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 @@ -830,6 +882,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 +907,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 @@ -867,6 +921,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 @@ -879,6 +934,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
enable-tiered-cache: true
- use: frontend
Expand All @@ -891,6 +947,7 @@ profile:
- use: etcd
unsafe-no-fsync: true
- use: meta-node
meta-backend: etcd
- use: compute-node
port: 5687
exporter-port: 1222
Expand All @@ -912,6 +969,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
enable-tiered-cache: true
- use: frontend
Expand All @@ -927,6 +985,7 @@ profile:
- use: etcd
- use: minio
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand All @@ -943,6 +1002,7 @@ profile:
- use: sqlite
- use: minio
- use: meta-node
meta-backend: sqlite
- use: compute-node
- use: frontend
- use: compactor
Expand Down Expand Up @@ -993,6 +1053,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand All @@ -1004,6 +1065,7 @@ profile:
bucket: renjie-iceberg-bench
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand All @@ -1016,6 +1078,7 @@ profile:
- use: minio
- use: etcd
- use: meta-node
meta-backend: etcd
- use: compute-node
- use: frontend
- use: compactor
Expand Down Expand Up @@ -1176,12 +1239,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 @@ -1476,3 +1545,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.
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>>,

/// 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 @@ -222,7 +222,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
16 changes: 13 additions & 3 deletions src/risedevtool/src/bin/risedev-dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +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, ZooKeeperService,
RISEDEV_NAME,
GrafanaService, KafkaService, MetaNodeService, MinioService, MySqlService, PostgresService,
PrometheusService, PubsubService, RedisService, ServiceConfig, SqliteConfig, Task,
TempoService, ZooKeeperService, RISEDEV_NAME,
};
use tempfile::tempdir;
use thiserror_ext::AsReport;
Expand Down Expand Up @@ -326,6 +326,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
Loading
Loading