mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-11-26 03:23:07 +01:00
Port importer to new transaction api
This commit is contained in:
@@ -55,7 +55,18 @@ func InitDB() error {
|
|||||||
|
|
||||||
// Bundle 100 inserts into one transaction for better performance
|
// Bundle 100 inserts into one transaction for better performance
|
||||||
if i%100 == 0 {
|
if i%100 == 0 {
|
||||||
r.TransactionCommit(t)
|
if i > 0 {
|
||||||
|
if err := t.Commit(); err != nil {
|
||||||
|
cclog.Errorf("transaction commit error: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Start a new transaction for the next batch
|
||||||
|
t, err = r.TransactionInit()
|
||||||
|
if err != nil {
|
||||||
|
cclog.Errorf("transaction init error: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
fmt.Printf("%d jobs inserted...\r", i)
|
fmt.Printf("%d jobs inserted...\r", i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user