Skip to content

Commit

Permalink
Bug fix[DB-15480]: Calculation of IOPs based on iops capture interval…
Browse files Browse the repository at this point in the history
… provided by the user (#2352)

- due to the bug voyager was always using 120seconds, which is default, even when user provides the input
  • Loading branch information
sanyamsinghal authored Mar 3, 2025
1 parent 7da25cc commit e042115
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions yb-voyager/cmd/assessMigrationCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ func assessMigration() (err error) {
assessmentDir := filepath.Join(exportDir, "assessment")
migassessment.AssessmentDir = assessmentDir
migassessment.SourceDBType = source.DBType
migassessment.IntervalForCapturingIops = intervalForCapturingIOPS

if source.Password == "" {
source.Password, err = askPassword("source DB", source.User, "SOURCE_DB_PASSWORD")
Expand Down
25 changes: 16 additions & 9 deletions yb-voyager/src/migassessment/assessmentDB.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@ const (
initial.schema_name,
initial.object_name,
initial.object_type,
(final.seq_reads - initial.seq_reads) / 120 AS seq_reads_per_second,
(final.row_writes - initial.row_writes) / 120 AS row_writes_per_second
(final.seq_reads - initial.seq_reads) / %d AS seq_reads_per_second, -- iops capture interval(default: 120)
(final.row_writes - initial.row_writes) / %d AS row_writes_per_second
FROM
%s AS initial
JOIN
%s AS final ON initial.schema_name = final.schema_name
AND initial.object_name = final.object_name
AND final.measurement_type = 'final'
AND initial.object_name = final.object_name
AND final.measurement_type = 'final'
WHERE
initial.measurement_type = 'initial';`

Expand All @@ -273,11 +273,11 @@ const (
reads_per_second = (SELECT seq_reads_per_second
FROM read_write_rates
WHERE read_write_rates.schema_name = table_index_stats.schema_name
AND read_write_rates.object_name = table_index_stats.object_name),
AND read_write_rates.object_name = table_index_stats.object_name),
writes_per_second = (SELECT row_writes_per_second
FROM read_write_rates
WHERE read_write_rates.schema_name = table_index_stats.schema_name
AND read_write_rates.object_name = table_index_stats.object_name)
FROM read_write_rates
WHERE read_write_rates.schema_name = table_index_stats.schema_name
AND read_write_rates.object_name = table_index_stats.object_name)
WHERE EXISTS (
SELECT 1
FROM read_write_rates
Expand All @@ -297,8 +297,15 @@ func (adb *AssessmentDB) PopulateMigrationAssessmentStats() error {

switch SourceDBType {
case constants.POSTGRESQL:
var createTempTableForIops string
if IntervalForCapturingIops == 0 { // considering value as 0 to avoid division by zero
createTempTableForIops = fmt.Sprintf(CreateTempTable, 1, 1, TABLE_INDEX_IOPS, TABLE_INDEX_IOPS)
} else {
createTempTableForIops = fmt.Sprintf(CreateTempTable, IntervalForCapturingIops, IntervalForCapturingIops, TABLE_INDEX_IOPS, TABLE_INDEX_IOPS)
}

statements = append(statements,
fmt.Sprintf(CreateTempTable, TABLE_INDEX_IOPS, TABLE_INDEX_IOPS),
createTempTableForIops,
UpdateStatsWithRates)
case constants.ORACLE:
// already accounted
Expand Down
1 change: 1 addition & 0 deletions yb-voyager/src/migassessment/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

var AssessmentDir string
var SourceDBType string
var IntervalForCapturingIops int64

type Record map[string]any

Expand Down

0 comments on commit e042115

Please sign in to comment.