func cleanUpCheck(sess sqlbuilder.Database) (err error) { var stats map[string]int stats, err = getStats(sess) if err != nil { return err } if activeStatements := sqladapter.NumActiveStatements(); activeStatements > 128 { return fmt.Errorf("Expecting active statements to be at most 128, got %d", activeStatements) } sess.ClearCache() if activeStatements := sqladapter.NumActiveStatements(); activeStatements != 0 { return fmt.Errorf("Expecting active statements to be 0, got %d", activeStatements) } for i := 0; i < 10; i++ { stats, err = getStats(sess) if err != nil { return err } if stats["Prepared_stmt_count"] != 0 { time.Sleep(time.Millisecond * 200) // Sometimes it takes a bit to clean prepared statements err = fmt.Errorf(`Expecting "Prepared_stmt_count" to be 0, got %d`, stats["Prepared_stmt_count"]) continue } break } return err }
func cleanUpCheck(sess sqlbuilder.Database) (err error) { var stats map[string]int stats, err = getStats(sess) if err != nil { return err } if activeStatements := sqladapter.NumActiveStatements(); activeStatements > 128 { return fmt.Errorf("Expecting active statements to be at most 128, got %d", activeStatements) } sess.ClearCache() stats, err = getStats(sess) if err != nil { return err } if stats["pg_prepared_statements_count"] != 0 { return fmt.Errorf(`Expecting "Prepared_stmt_count" to be 0, got %d`, stats["Prepared_stmt_count"]) } return nil }