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

Migration: error with negative downtime duration (uint64 values with high bit set are not supported) #625

Open
julianbrost opened this issue Jul 31, 2023 · 0 comments

Comments

@julianbrost
Copy link
Contributor

I ran into the following error when running icingadb-migration with PostgreSQL as the destination database:

2023-07-31T16:25:18.977+0200	FATAL	icingadb-migrate/main.go:435	sql: converting argument $227 type: uint64 values with high bit set are not supported
can't perform "INSERT INTO \"downtime_history\" (\"scheduled_by\", \"cancelled_by\", \"parent_id\", \"object_type\", \"service_id\", \"triggered_by_id\", \"flexible_duration\", \"is_flexible\", \"scheduled_start_time\", \"trigger_time\", \"endpoint_id\", \"downtime_id\", \"environment_id\", \"host_id\", \"has_been_cancelled\", \"author\", \"comment\", \"scheduled_end_time\", \"end_time\", \"start_time\", \"entry_time\", \"cancel_time\") VALUES (:scheduled_by, :cancelled_by, :parent_id, :object_type, :service_id, :triggered_by_id, :flexible_duration, :is_flexible, :scheduled_start_time, :trigger_time, :endpoint_id, :downtime_id, :environment_id, :host_id, :has_been_cancelled, :author, :comment, :scheduled_end_time, :end_time, :start_time, :entry_time, :cancel_time) ON CONFLICT ON CONSTRAINT pk_downtime_history DO NOTHING"
Full error
2023-07-31T16:25:18.977+0200	FATAL	icingadb-migrate/main.go:435	sql: converting argument $227 type: uint64 values with high bit set are not supported
can't perform "INSERT INTO \"downtime_history\" (\"scheduled_by\", \"cancelled_by\", \"parent_id\", \"object_type\", \"service_id\", \"triggered_by_id\", \"flexible_duration\", \"is_flexible\", \"scheduled_start_time\", \"trigger_time\", \"endpoint_id\", \"downtime_id\", \"environment_id\", \"host_id\", \"has_been_cancelled\", \"author\", \"comment\", \"scheduled_end_time\", \"end_time\", \"start_time\", \"entry_time\", \"cancel_time\") VALUES (:scheduled_by, :cancelled_by, :parent_id, :object_type, :service_id, :triggered_by_id, :flexible_duration, :is_flexible, :scheduled_start_time, :trigger_time, :endpoint_id, :downtime_id, :environment_id, :host_id, :has_been_cancelled, :author, :comment, :scheduled_end_time, :end_time, :start_time, :entry_time, :cancel_time) ON CONFLICT ON CONSTRAINT pk_downtime_history DO NOTHING"
github.com/icinga/icingadb/internal.CantPerformQuery
	/home/jbrost/src/icingadb/internal/internal.go:30
github.com/icinga/icingadb/pkg/icingadb.(*DB).NamedBulkExec.func1.1.1.1
	/home/jbrost/src/icingadb/pkg/icingadb/db.go:391
github.com/icinga/icingadb/pkg/retry.WithBackoff
	/home/jbrost/src/icingadb/pkg/retry/retry.go:49
github.com/icinga/icingadb/pkg/icingadb.(*DB).NamedBulkExec.func1.1.1
	/home/jbrost/src/icingadb/pkg/icingadb/db.go:386
golang.org/x/sync/errgroup.(*Group).Go.func1
	/home/jbrost/.local/share/go/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75
runtime.goexit
	/usr/lib/go/src/runtime/asm_amd64.s:1598
can't retry
github.com/icinga/icingadb/pkg/retry.WithBackoff
	/home/jbrost/src/icingadb/pkg/retry/retry.go:68
github.com/icinga/icingadb/pkg/icingadb.(*DB).NamedBulkExec.func1.1.1
	/home/jbrost/src/icingadb/pkg/icingadb/db.go:386
golang.org/x/sync/errgroup.(*Group).Go.func1
	/home/jbrost/.local/share/go/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75
runtime.goexit
	/usr/lib/go/src/runtime/asm_amd64.s:1598
can't perform DML
main.migrateOneType[...].func3
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/main.go:435
main.sliceIdoHistory[...]
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/misc.go:135
main.migrateOneType[...]
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/main.go:421
main.glob..func3
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/misc.go:266
main.migrate.func1
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/main.go:359
main.historyTypes.forEach.func1
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/misc.go:232
golang.org/x/sync/errgroup.(*Group).Go.func1
	/home/jbrost/.local/share/go/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75
runtime.goexit
	/usr/lib/go/src/runtime/asm_amd64.s:1598	{"backend": "Icinga DB", "op": "INSERT IGNORE", "table": "downtime_history"}
main.migrateOneType[...].func3
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/main.go:435
main.sliceIdoHistory[...]
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/misc.go:135
main.migrateOneType[...]
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/main.go:421
main.glob..func3
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/misc.go:266
main.migrate.func1
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/main.go:359
main.historyTypes.forEach.func1
	/home/jbrost/src/icingadb/cmd/icingadb-migrate/misc.go:232
golang.org/x/sync/errgroup.(*Group).Go.func1
	/home/jbrost/.local/share/go/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75

This row form icinga_downtimehistory seems to cause the problem:

*************************** 1. row ***************************
    downtimehistory_id: 27450
           instance_id: 1
         downtime_type: 1
             object_id: 324
            entry_time: 2023-05-25 15:09:46
           author_name: icingaadmin
          comment_data: gdfg
  internal_downtime_id: 11
       triggered_by_id: NULL
              is_fixed: 0
              duration: -3660
  scheduled_start_time: 2023-05-25 15:09:36
    scheduled_end_time: 2023-05-25 16:09:38
           was_started: 1
     actual_start_time: 2023-05-25 15:09:46
actual_start_time_usec: 692550
       actual_end_time: 2023-05-25 15:09:46
  actual_end_time_usec: 695005
         was_cancelled: 0
          is_in_effect: 0
          trigger_time: 2023-05-25 15:09:46
                  name: master-1!icinga-cluster!8f51e5dc-7ee7-4110-9c83-d28b5f8065fc
    endpoint_object_id: 239

It's probably this conversion overflowing and generating a garbage value:

FlexibleDuration: uint64(row.Duration) * 1000,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant