Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

writeManyInstances: improve error message if we run out of placeholders. #1265

Merged
merged 1 commit into from
Nov 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions go/inst/instance_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -2639,6 +2639,14 @@ func mkInsertOdkuForInstances(instances []*Instance, instanceWasActuallyFound bo
}

// writeManyInstances stores instances in the orchestrator backend
//
// This may trigger this error: Error 1390: Prepared statement contains too
// many placeholders if you are monitoring several thousand servers as it
// may trigger the total number of place holders to exceed (uint)UINT_MAX16
// in the MySQL source code.

const tooManyPlaceholders = "Error 1390: Prepared statement contains too many placeholders"

func writeManyInstances(instances []*Instance, instanceWasActuallyFound bool, updateLastSeen bool) error {
writeInstances := [](*Instance){}
for _, instance := range instances {
Expand All @@ -2655,6 +2663,14 @@ func writeManyInstances(instances []*Instance, instanceWasActuallyFound bool, up
return err
}
if _, err := db.ExecOrchestrator(sql, args...); err != nil {
if strings.Contains(err.Error(), tooManyPlaceholders) {
return fmt.Errorf("writeManyInstances(?,%v,%v): error: %+v, len(instances): %v, len(args): %v. Reduce InstanceWriteBufferSize to avoid len(args) being > 64k, a limit in the MySQL source code.",
instanceWasActuallyFound,
updateLastSeen,
err.Error(),
len(writeInstances),
len(args))
}
return err
}
return nil
Expand Down