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

Commit

Permalink
Merge pull request #1265 from sjmudd/sjmudd/too_many_placeholders
Browse files Browse the repository at this point in the history
thank you
  • Loading branch information
shlomi-noach authored Nov 17, 2020
2 parents e864095 + ccf2596 commit 97eb9c2
Showing 1 changed file with 16 additions and 0 deletions.
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

0 comments on commit 97eb9c2

Please sign in to comment.