Skip to content

Commit

Permalink
fix(gorgone): mbi unable to rebuild partial data with new scripts (#1190
Browse files Browse the repository at this point in the history
)
  • Loading branch information
garnier-quentin authored Mar 31, 2023
1 parent 6d898ac commit ab50fcf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
19 changes: 14 additions & 5 deletions gorgone/gorgone/modules/centreon/mbi/etl/event/main.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,22 @@ sub deleteEntriesForRebuild {
"DELETE FROM $options{name} WHERE time_id >= " . $utils->getDateEpoch($options{start}) . " AND time_id < " . $utils->getDateEpoch($options{end})
];
} else {
my $structure = $biTables->dumpTableStructure($options{name});
my $partitionsPerf = $utils->getRangePartitionDate($options{start}, $options{end});
foreach (@$partitionsPerf) {
push @$sql,
[
"[PURGE] Truncate partition $_->{name} on table [$options{name}]",
"ALTER TABLE $options{name} TRUNCATE PARTITION p$_->{name}"
];
if ($structure =~ /p$_->{name}/m) {
push @$sql,
[
"[PURGE] Truncate partition $_->{name} on table [$options{name}]",
"ALTER TABLE $options{name} TRUNCATE PARTITION p$_->{name}"
];
} else {
push @$sql,
[
'[PARTITIONS] Add partition [p' . $_->{name} . '] on table [' . $options{name} . ']',
"ALTER TABLE `$options{name}` ADD PARTITION (PARTITION `p$_->{name}` VALUES LESS THAN(" . $_->{epoch} . "))"
];
}
}
}

Expand Down
19 changes: 14 additions & 5 deletions gorgone/gorgone/modules/centreon/mbi/etl/perfdata/main.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,22 @@ sub deleteEntriesForRebuild {
"DELETE FROM $options{name} WHERE time_id >= " . $utils->getDateEpoch($options{start}) . " AND time_id < " . $utils->getDateEpoch($options{end})
];
} else {
my $structure = $biTables->dumpTableStructure($options{name});
my $partitionsPerf = $utils->getRangePartitionDate($options{start}, $options{end});
foreach (@$partitionsPerf) {
push @$sql,
[
"[PURGE] Truncate partition $_->{name} on table [$options{name}]",
"ALTER TABLE $options{name} TRUNCATE PARTITION p$_->{name}"
];
if ($structure =~ /p$_->{name}/m) {
push @$sql,
[
"[PURGE] Truncate partition $_->{name} on table [$options{name}]",
"ALTER TABLE $options{name} TRUNCATE PARTITION p$_->{name}"
];
} else {
push @$sql,
[
'[PARTITIONS] Add partition [p' . $_->{name} . '] on table [' . $options{name} . ']',
"ALTER TABLE `$options{name}` ADD PARTITION (PARTITION `p$_->{name}` VALUES LESS THAN(" . $_->{epoch} . "))"
];
}
}
}

Expand Down

0 comments on commit ab50fcf

Please sign in to comment.