mirror of
https://github.com/Icinga/icingadb.git
synced 2026-06-09 00:42:37 -04:00
cmd/ido2icingadb: remove unnecessary transactions
for the sake of speed.
This commit is contained in:
parent
690fcfa190
commit
23130d7be8
2 changed files with 3 additions and 12 deletions
|
|
@ -356,11 +356,6 @@ func migrateOneType[IdoRow any](
|
|||
|
||||
// ... and insert them:
|
||||
|
||||
tx, err := idb.Beginx()
|
||||
if err != nil {
|
||||
log.With("backend", "Icinga DB").Fatalf("%+v", errors.Wrap(err, "can't begin transaction"))
|
||||
}
|
||||
|
||||
for _, op := range []struct {
|
||||
data [][]any
|
||||
stmtBuilder func(any) (string, int)
|
||||
|
|
@ -383,7 +378,7 @@ func migrateOneType[IdoRow any](
|
|||
context.Background(), ch, idb.BatchSizeByPlaceholders(placeholders), com.NeverSplit[any],
|
||||
)
|
||||
for rows := range bulk {
|
||||
if _, err := tx.NamedExec(query, rows); err != nil {
|
||||
if _, err := idb.NamedExec(query, rows); err != nil {
|
||||
log.With("backend", "Icinga DB", "dml", query, "args", rows).
|
||||
Fatalf("%+v", errors.Wrap(err, "can't perform DML"))
|
||||
}
|
||||
|
|
@ -394,7 +389,7 @@ func migrateOneType[IdoRow any](
|
|||
if lastIdoId != nil {
|
||||
args := map[string]interface{}{"history_type": ht.name, "last_ido_id": lastIdoId}
|
||||
|
||||
_, err := tx.NamedExec(upsertProgress, &IdoMigrationProgress{
|
||||
_, err := idb.NamedExec(upsertProgress, &IdoMigrationProgress{
|
||||
IdoMigrationProgressUpserter{lastIdoId}, envIdHex, ht.name,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -403,10 +398,6 @@ func migrateOneType[IdoRow any](
|
|||
}
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
log.With("backend", "Icinga DB").Fatalf("%+v", errors.Wrap(err, "can't commit transaction"))
|
||||
}
|
||||
|
||||
ht.bar.IncrBy(len(idoRows))
|
||||
return lastIdoId
|
||||
},
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ func sliceIdoHistory[Row any](
|
|||
}
|
||||
|
||||
args["checkpoint"] = checkpoint
|
||||
args["bulk"] = 100
|
||||
args["bulk"] = 10000
|
||||
|
||||
if snapshot.DriverName() != driver.MySQL {
|
||||
query = strings.ReplaceAll(query, " USE INDEX (PRIMARY)", "")
|
||||
|
|
|
|||
Loading…
Reference in a new issue