Skip to content

something not very well under multi threads #183

@starxchina

Description

@starxchina
func (m *Measurement) getHist(op string, err error, current bool) *Histogram {
	opMeasurement := m.OpSumMeasurement
	if current {
		opMeasurement = m.OpCurMeasurement
	}

	// Create hist of {op} and {op}_ERR at the same time, or else the TPM would be incorrect
	opPairedKey := fmt.Sprintf("%s_ERR", op)
	if err != nil {
		op, opPairedKey = opPairedKey, op
	}

	m.RLock()
	opM, ok := opMeasurement[op]
	m.RUnlock()
	if !ok {
		opM = NewHistogram(m.MinLatency, m.MaxLatency, m.SigFigs)
		opPairedM := NewHistogram(m.MinLatency, m.MaxLatency, m.SigFigs)
		m.Lock()
		opMeasurement[op] = opM
		opMeasurement[opPairedKey] = opPairedM
		m.Unlock()
	}
	return opM
}

there will exist data loss under multi threads in pkg/measurement/measure.go: if !ok {...}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions