Repository: pingcap/tidb
File: pkg/executor/insert.go (Go)

Code before:
			if !e.row4Update[assign.Col.Index].Equals(val) {
				realOverwrite = true
			}
			if assign.ColName.Equals(&model.ExtraOriginTSName) {
				if newRow[updateOriginTSCol].Equals(val) {
					originTSEqual = true
				}
			}
		}
		e.row4Update[assign.Col.Index] = val
		assignFlag[assign.Col.Index] = true
	}

	if needActiveActiveSyncStats && len(nonGenerated) > 0 && !realOverwrite {
		// ActiveActiveSyncStats info is required, but no overwrite really happen, it means
		// that all conflicts are skipped.
		// _tidb_origin_ts equal is a corner case, imagine that CDC sync duplicate rows, with same _tidb_origin_ts
		// In this case, the skipped row is not caused by business logic, but CDC, we should not give misleading information.
		if !originTSEqual {
			e.Ctx().GetSessionVars().ActiveActiveConflictSkipRows.Add(1)
			logutil.BgLogger().Info("[CDC active-active] skip writing conflict row.",
				zap.Stringer("table", e.Table.Meta().Name),
				zap.Int64("table-id", e.Table.Meta().ID),
				zap.Stringer("handle", handle),
				zap.String("old row", types.DatumsToStrNoErr(oldRow)),
				zap.String("new row", types.DatumsToStrNoErr(newRow)))
		}
	}

	newData := e.row4Update[:len(e.Table.WritableCols())]
	if updateOriginTSCol >= 0 && !assignFlag[updateOriginTSCol] {
		newData[updateOriginTSCol].SetNull()
	}

	_, ignored, err := updateRecord(
		ctx, e.Ctx(),
		handle, oldRow, newData,
		0, generated, e.evalBuffer4Dup, errorHandler,
		assignFlag, e.Table,
		true, e.memTracker, e.fkChecks, e.fkCascades, dupKeyMode, e.ignoreErr)

	if ignored {
		return nil
	}

	if err != nil {
		return errors.Trace(err)
	}

	if autoColIdx >= 0 {
		if e.Ctx().GetSessionVars().StmtCtx.AffectedRows() > 0 {

Review comment (suggestion):
I think we do not need to log the old and new row in case the row is too large. We should log extra fields:

- oldRow's commit ts
- oldRow's orgin ts
- newRow's origin ts

Code after:

		_ = errorHandler(sctx, assign, &val, nil)
		e.evalBuffer4Dup.SetDatum(idx, val)
		if needActiveActiveSyncStats {
			if !e.row4Update[assign.Col.Index].Equals(val) {
				realOverwrite = true
			}
			if assign.ColName.Equals(&model.ExtraOriginTSName) {
				if newRow[updateOriginTSCol].Equals(val) {
					originTSEqual = true
				}
			}
		}
		e.row4Update[assign.Col.Index] = val
		assignFlag[assign.Col.Index] = true
	}

	// ActiveActiveSyncStats info is required, but no overwrite really happen, it means
	// that all conflicts are skipped.
	if needActiveActiveSyncStats && len(nonGenerated) > 0 && !realOverwrite {
		// _tidb_origin_ts equal is a corner case, imagine that CDC sync duplicate rows, with same _tidb_origin_ts
		// In this case, the skipped row is not caused by business logic, but CDC, we should not give misleading information.
		if !originTSEqual {
			e.Ctx().GetSessionVars().ActiveActiveConflictSkipRows.Add(1)
			redactMode := e.Ctx().GetSessionVars().EnableRedactLog
			oldRowOriginTS, _ := oldRow[updateOriginTSCol].ToString()
			newRowOriginTS, _ := newRow[updateOriginTSCol].ToString()
			logutil.BgLogger().Info("[CDC active-active] skip writing conflict row.",
				zap.Int64("tableID", e.Table.Meta().ID),
				zap.Stringer("table", e.Table.Meta().Name),
				zap.Stringer("handle", redact.Stringer(redactMode, handle)),
				zap.Uint64("old row commit ts", oldRowCommitTS),
				zap.String("old row origin ts", oldRowOriginTS),
				zap.String("new row origin ts", newRowOriginTS))
		}
	}

	newData := e.row4Update[:len(e.Table.WritableCols())]
	if updateOriginTSCol >= 0 && !assignFlag[updateOriginTSCol] {
		newData[updateOriginTSCol].SetNull()
	}

	_, ignored, err := updateRecord(
		ctx, e.Ctx(),
		handle, oldRow, newData,
		0, generated, e.evalBuffer4Dup, errorHandler,
		assignFlag, e.Table,
		true, e.memTracker, e.fkChecks, e.fkCascades, dupKeyMode, e.ignoreErr)

	if ignored {
		return nil