| 563 | } |
| 564 | |
| 565 | func (s *State) commit() (err error) { |
| 566 | var ( |
| 567 | start = time.Now() |
| 568 | |
| 569 | lockAcquired, committed, poolCleaned, lockReleased time.Duration |
| 570 | ) |
| 571 | |
| 572 | defer func() { |
| 573 | var fields = log.Fields{} |
| 574 | fields["1#lockAcquired"] = float64(lockAcquired.Nanoseconds()) / 1000 |
| 575 | if committed > 0 { |
| 576 | fields["2#committed"] = float64((committed - lockAcquired).Nanoseconds()) / 1000 |
| 577 | } |
| 578 | if poolCleaned > 0 { |
| 579 | fields["3#poolCleaned"] = float64((poolCleaned - committed).Nanoseconds()) / 1000 |
| 580 | } |
| 581 | if lockReleased > 0 { |
| 582 | fields["4#lockReleased"] = float64((lockReleased - poolCleaned).Nanoseconds()) / 1000 |
| 583 | } |
| 584 | log.WithFields(fields).Debug("Commit duration stat (us)") |
| 585 | }() |
| 586 | |
| 587 | s.Lock() |
| 588 | defer func() { |
| 589 | s.Unlock() |
| 590 | lockReleased = time.Since(start) |
| 591 | }() |
| 592 | lockAcquired = time.Since(start) |
| 593 | s.flushHandler() |
| 594 | committed = time.Since(start) |
| 595 | _ = s.pool.queries |
| 596 | s.pool = newPool() |
| 597 | poolCleaned = time.Since(start) |
| 598 | return |
| 599 | } |
| 600 | |
| 601 | // CommitEx commits the current transaction and returns all the pooled queries. |
| 602 | func (s *State) CommitEx() (failed []*types.Request, queries []*QueryTracker, err error) { |