@@ -799,31 +799,34 @@ initStats(StatsData *sd, double start_time)
799
799
}
800
800
801
801
/*
802
- * Accumulate one additional item into the given stats object.
802
+ * Accumulate statistics regardless of whether there was a failure / transaction
803
+ * was skipped or not.
803
804
*/
804
805
static void
805
- accumStats (StatsData * stats , bool skipped , bool serialization_failure ,
806
- bool deadlock_failure , double lat , double lag , SimpleStats * attempts )
806
+ accumMainStats (StatsData * stats , bool skipped , bool serialization_failure ,
807
+ bool deadlock_failure , SimpleStats * attempts )
807
808
{
808
809
stats -> cnt ++ ;
809
- mergeSimpleStats (& stats -> attempts , attempts );
810
-
811
810
if (skipped )
812
- {
813
- /* no latency to record on skipped transactions */
814
811
stats -> skipped ++ ;
815
- }
816
812
else if (serialization_failure )
817
- {
818
- /* no latency to record on transactions with serialization failures */
819
813
stats -> serialization_failures ++ ;
820
- }
821
814
else if (deadlock_failure )
822
- {
823
- /* no latency to record on transactions with deadlock failures */
824
815
stats -> deadlock_failures ++ ;
825
- }
826
- else
816
+ mergeSimpleStats (& stats -> attempts , attempts );
817
+ }
818
+
819
+ /*
820
+ * Accumulate one additional item into the given stats object.
821
+ */
822
+ static void
823
+ accumStats (StatsData * stats , bool skipped , bool serialization_failure ,
824
+ bool deadlock_failure , double lat , double lag , SimpleStats * attempts )
825
+ {
826
+ accumMainStats (stats , skipped , serialization_failure , deadlock_failure ,
827
+ attempts );
828
+
829
+ if (!skipped && !serialization_failure && !deadlock_failure )
827
830
{
828
831
addToSimpleStats (& stats -> latency , lat );
829
832
@@ -2168,18 +2171,11 @@ doCustom(TState *thread, CState *st, StatsData *agg)
2168
2171
{
2169
2172
if (progress || throttle_delay || latency_limit ||
2170
2173
per_script_stats || use_log )
2171
- {
2172
2174
processXactStats (thread , st , & now , false, agg );
2173
- }
2174
2175
else
2175
- {
2176
- thread -> stats .cnt ++ ;
2177
- if (st -> serialization_failure )
2178
- thread -> stats .serialization_failures ++ ;
2179
- if (st -> deadlock_failure )
2180
- thread -> stats .deadlock_failures ++ ;
2181
- mergeSimpleStats (& thread -> stats .attempts , & st -> attempts );
2182
- }
2176
+ accumMainStats (& thread -> stats , false,
2177
+ st -> serialization_failure , st -> deadlock_failure ,
2178
+ & st -> attempts );
2183
2179
}
2184
2180
2185
2181
if (commands [st -> state ]-> type == SQL_COMMAND )
@@ -2696,14 +2692,8 @@ processXactStats(TState *thread, CState *st, instr_time *now,
2696
2692
thread -> latency_late ++ ;
2697
2693
}
2698
2694
else
2699
- {
2700
- thread -> stats .cnt ++ ;
2701
- if (st -> serialization_failure )
2702
- thread -> stats .serialization_failures ++ ;
2703
- if (st -> deadlock_failure )
2704
- thread -> stats .deadlock_failures ++ ;
2705
- mergeSimpleStats (& thread -> stats .attempts , & st -> attempts );
2706
- }
2695
+ accumMainStats (& thread -> stats , skipped , st -> serialization_failure ,
2696
+ st -> deadlock_failure , & st -> attempts );
2707
2697
2708
2698
if (use_log )
2709
2699
doLog (thread , st , now , agg , skipped , latency , lag );
0 commit comments