Skip to content

feat(processing_engine): Store triggers by DbId and TriggerId instead of name #26186

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions influxdb3/tests/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2516,7 +2516,7 @@ def process_scheduled_call(influxdb3_local, schedule_time, args=None):
.unwrap();

// Wait for trigger to run several times
tokio::time::sleep(std::time::Duration::from_millis(3100)).await;
tokio::time::sleep(std::time::Duration::from_millis(5000)).await;

// Query to see what values were written before disabling
let first_query_result = server
Expand All @@ -2535,7 +2535,7 @@ def process_scheduled_call(influxdb3_local, schedule_time, args=None):
server.enable_trigger(db_name, trigger_name).run().unwrap();

// Wait for trigger to run again
tokio::time::sleep(std::time::Duration::from_millis(1100)).await;
tokio::time::sleep(std::time::Duration::from_millis(5000)).await;

// Query results after re-enabling
let second_query_result = server
Expand Down
7 changes: 3 additions & 4 deletions influxdb3_catalog/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,8 @@ impl Catalog {
self.inner.read().db_exists(db_id)
}

/// Get active triggers by database and trigger name
// NOTE: this could be id-based in future
pub fn active_triggers(&self) -> Vec<(Arc<str>, Arc<str>)> {
/// Get active triggers by database ID and trigger ID
pub fn active_triggers(&self) -> Vec<(DbId, TriggerId)> {
let inner = self.inner.read();
let result = inner
.databases
Expand All @@ -314,7 +313,7 @@ impl Catalog {
if trigger.disabled {
None
} else {
Some((Arc::clone(&db.name), Arc::clone(&trigger.trigger_name)))
Some((db.id, trigger.trigger_id))
}
})
})
Expand Down
1 change: 1 addition & 0 deletions influxdb3_catalog/src/catalog/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ impl Catalog {
db.id,
db.name(),
vec![DatabaseCatalogOp::CreateTrigger(TriggerDefinition {
database_id: db.id,
trigger_id,
trigger_name: trigger_name.into(),
plugin_filename: plugin_filename.to_string(),
Expand Down
1 change: 1 addition & 0 deletions influxdb3_catalog/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ pub struct TriggerDefinition {
pub trigger_id: TriggerId,
pub trigger_name: Arc<str>,
pub plugin_filename: String,
pub database_id: DbId,
pub database_name: Arc<str>,
pub node_id: Arc<str>,
pub trigger: TriggerSpecificationDefinition,
Expand Down
3 changes: 3 additions & 0 deletions influxdb3_catalog/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ impl Snapshot for TableDefinition {

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ProcessingEngineTriggerSnapshot {
pub database_id: DbId,
pub trigger_id: TriggerId,
pub trigger_name: Arc<str>,
pub node_id: Arc<str>,
Expand All @@ -227,6 +228,7 @@ impl Snapshot for TriggerDefinition {

fn snapshot(&self) -> Self::Serialized {
Self::Serialized {
database_id: self.database_id,
trigger_id: self.trigger_id,
trigger_name: Arc::clone(&self.trigger_name),
node_id: Arc::clone(&self.node_id),
Expand All @@ -241,6 +243,7 @@ impl Snapshot for TriggerDefinition {

fn from_snapshot(snap: Self::Serialized) -> Self {
Self {
database_id: snap.database_id,
trigger_id: snap.trigger_id,
trigger_name: snap.trigger_name,
node_id: snap.node_id,
Expand Down
1 change: 1 addition & 0 deletions influxdb3_processing_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ hyper.workspace = true
iox_time.workspace = true
influxdb3_catalog = { path = "../influxdb3_catalog" }
influxdb3_client = { path = "../influxdb3_client" }
influxdb3_id = { path = "../influxdb3_id" }
influxdb3_internal_api = { path = "../influxdb3_internal_api" }
influxdb3_py_api = { path = "../influxdb3_py_api" }
influxdb3_types = { path = "../influxdb3_types" }
Expand Down
Loading