From 7af6ba3dee5044d5e0725cd0b9c36668504d2595 Mon Sep 17 00:00:00 2001 From: Michael Erickson Date: Thu, 12 Aug 2021 23:09:52 -0700 Subject: [PATCH] sql: add sql.mutations.max_row_size.warn guardrail Addresses: #67400 Add sql.mutations.max_row_size.warn, a new cluster setting which controls large row logging. Rows larger than this size will have their keys logged to the SQL_PERF or SQL_INTERNAL_PERF channels whenever the SQL layer puts them into the KV layer. This logging takes place in rowHelper, which is used by both row.Inserter and row.Updater. Most of the work is plumbing settings.Values and SessionData into rowHelper, and adding a new structured event type. Release note (ops change): A new cluster setting, sql.mutations.max_row_size.warn, was added, which controls large row logging. Whenever a row larger than this size is added (or a simgle column family if multiple column families are in use) a LargeRow event is logged to the SQL_PERF channel (or a LargeRowInternal event is logged to SQL_INTERNAL_PERF if the row was added by an internal query). This could occur for INSERT, UPSERT, UPDATE, CREATE TABLE AS, CREATE INDEX, ALTER TABLE, ALTER INDEX, IMPORT, or RESTORE statements. --- docs/generated/eventlog.md | 45 + .../settings/settings-for-tenants.txt | 1 + docs/generated/settings/settings.html | 1 + pkg/ccl/importccl/import_stmt.go | 4 +- pkg/kv/kvserver/replica.go | 13 +- pkg/sql/backfill.go | 14 +- pkg/sql/backfill/backfill.go | 2 + pkg/sql/create_table.go | 5 +- pkg/sql/gcjob/BUILD.bazel | 1 + pkg/sql/gcjob/table_garbage_collection.go | 8 +- pkg/sql/opt_exec_factory.go | 32 +- pkg/sql/row/BUILD.bazel | 3 + pkg/sql/row/deleter.go | 9 +- pkg/sql/row/helper.go | 84 +- pkg/sql/row/inserter.go | 11 +- pkg/sql/row/row_converter.go | 2 + pkg/sql/row/updater.go | 16 +- pkg/sql/row/writer.go | 10 + pkg/sql/truncate.go | 3 +- .../eventpb/eventlog_channels_generated.go | 6 + pkg/util/log/eventpb/json_encode_generated.go | 83 ++ pkg/util/log/eventpb/sql_audit_events.pb.go | 904 ++++++++++++++++-- pkg/util/log/eventpb/sql_audit_events.proto | 28 + 23 files changed, 1175 insertions(+), 110 deletions(-) diff --git a/docs/generated/eventlog.md b/docs/generated/eventlog.md index 433da0ce6d4e..ec27fdd9ad2f 100644 --- a/docs/generated/eventlog.md +++ b/docs/generated/eventlog.md @@ -1827,6 +1827,28 @@ are only emitted via external logging. Events in this category are logged to the `SQL_PERF` channel. +### `large_row` + +An event of type `large_row` is recorded when a row larger than cluster setting +`sql.mutations.max_row_size.warn` is added to the database. A single +statement could cause multiple LargeRow events to be emitted. + + + + +#### Common fields + +| Field | Description | Sensitive | +|--|--|--| +| `Timestamp` | The timestamp of the event. Expressed as nanoseconds since the Unix epoch. | no | +| `EventType` | The type of the event. | no | +| `RowSize` | | no | +| `MaxRowSize` | | no | +| `TableID` | | no | +| `IndexID` | | no | +| `FamilyID` | | no | +| `Key` | | yes | + ### `slow_query` An event of type `slow_query` is recorded when a query triggers the "slow query" condition. @@ -1877,6 +1899,29 @@ are only emitted via external logging. Events in this category are logged to the `SQL_INTERNAL_PERF` channel. +### `large_row_internal` + +An event of type `large_row_internal` is recorded when a row larger than cluster setting +`sql.mutations.max_row_size.warn` is added to the database by an internal +query. A single internal query could cause multiple LargeRowInternal events +to be emitted. + + + + +#### Common fields + +| Field | Description | Sensitive | +|--|--|--| +| `Timestamp` | The timestamp of the event. Expressed as nanoseconds since the Unix epoch. | no | +| `EventType` | The type of the event. | no | +| `RowSize` | | no | +| `MaxRowSize` | | no | +| `TableID` | | no | +| `IndexID` | | no | +| `FamilyID` | | no | +| `Key` | | yes | + ### `slow_query_internal` An event of type `slow_query_internal` is recorded when a query triggers the "slow query" condition, diff --git a/docs/generated/settings/settings-for-tenants.txt b/docs/generated/settings/settings-for-tenants.txt index 2b537facc2cd..fd383b8a546d 100644 --- a/docs/generated/settings/settings-for-tenants.txt +++ b/docs/generated/settings/settings-for-tenants.txt @@ -128,6 +128,7 @@ sql.metrics.statement_details.plan_collection.period duration 5m0s the time unti sql.metrics.statement_details.threshold duration 0s minimum execution time to cause statement statistics to be collected. If configured, no transaction stats are collected. sql.metrics.transaction_details.enabled boolean true collect per-application transaction statistics sql.multiregion.drop_primary_region.enabled boolean true allows dropping the PRIMARY REGION of a database if it is the last region +sql.mutations.max_row_size.warn byte size 64 MiB maximum size of row (or column family if multiple column families are in use) that SQL can write to the KV store, above which an event is logged to SQL_PERF or SQL_INTERNAL_PERF (setting to 0 disables large row logging) sql.notices.enabled boolean true enable notices in the server/client protocol being sent sql.optimizer.uniqueness_checks_for_gen_random_uuid.enabled boolean false if enabled, uniqueness checks may be planned for mutations of UUID columns updated with gen_random_uuid(); otherwise, uniqueness is assumed due to near-zero collision probability sql.spatial.experimental_box2d_comparison_operators.enabled boolean false enables the use of certain experimental box2d comparison operators diff --git a/docs/generated/settings/settings.html b/docs/generated/settings/settings.html index 586c80212b0c..f8e8bcef8722 100644 --- a/docs/generated/settings/settings.html +++ b/docs/generated/settings/settings.html @@ -132,6 +132,7 @@ sql.metrics.statement_details.thresholdduration0sminimum execution time to cause statement statistics to be collected. If configured, no transaction stats are collected. sql.metrics.transaction_details.enabledbooleantruecollect per-application transaction statistics sql.multiregion.drop_primary_region.enabledbooleantrueallows dropping the PRIMARY REGION of a database if it is the last region +sql.mutations.max_row_size.warnbyte size64 MiBmaximum size of row (or column family if multiple column families are in use) that SQL can write to the KV store, above which an event is logged to SQL_PERF or SQL_INTERNAL_PERF (setting to 0 disables large row logging) sql.notices.enabledbooleantrueenable notices in the server/client protocol being sent sql.optimizer.uniqueness_checks_for_gen_random_uuid.enabledbooleanfalseif enabled, uniqueness checks may be planned for mutations of UUID columns updated with gen_random_uuid(); otherwise, uniqueness is assumed due to near-zero collision probability sql.spatial.experimental_box2d_comparison_operators.enabledbooleanfalseenables the use of certain experimental box2d comparison operators diff --git a/pkg/ccl/importccl/import_stmt.go b/pkg/ccl/importccl/import_stmt.go index 0dd4096f8e9e..f9bbfff87196 100644 --- a/pkg/ccl/importccl/import_stmt.go +++ b/pkg/ccl/importccl/import_stmt.go @@ -2512,7 +2512,9 @@ func (r *importResumer) dropTables( // older-format (v1.1) descriptor. This enables ClearTableData to use a // RangeClear for faster data removal, rather than removing by chunks. empty[i].TableDesc().DropTime = dropTime - if err := gcjob.ClearTableData(ctx, execCfg.DB, execCfg.DistSender, execCfg.Codec, empty[i]); err != nil { + if err := gcjob.ClearTableData( + ctx, execCfg.DB, execCfg.DistSender, execCfg.Codec, &execCfg.Settings.SV, empty[i], + ); err != nil { return errors.Wrapf(err, "clearing data for table %d", empty[i].GetID()) } } diff --git a/pkg/kv/kvserver/replica.go b/pkg/kv/kvserver/replica.go index 347fcd0e852d..212165185149 100644 --- a/pkg/kv/kvserver/replica.go +++ b/pkg/kv/kvserver/replica.go @@ -90,15 +90,20 @@ var disableSyncRaftLog = settings.RegisterBoolSetting( false, ) -// MaxCommandSizeFloor is the minimum allowed value for the MaxCommandSize -// cluster setting. -const MaxCommandSizeFloor = 4 << 20 // 4MB +const ( + // MaxCommandSizeFloor is the minimum allowed value for the + // kv.raft.command.max_size cluster setting. + MaxCommandSizeFloor = 4 << 20 // 4MB + // MaxCommandSizeDefault is the default for the kv.raft.command.max_size + // cluster setting. + MaxCommandSizeDefault = 64 << 20 +) // MaxCommandSize wraps "kv.raft.command.max_size". var MaxCommandSize = settings.RegisterByteSizeSetting( "kv.raft.command.max_size", "maximum size of a raft command", - 64<<20, + MaxCommandSizeDefault, func(size int64) error { if size < MaxCommandSizeFloor { return fmt.Errorf("max_size must be greater than %s", humanizeutil.IBytes(MaxCommandSizeFloor)) diff --git a/pkg/sql/backfill.go b/pkg/sql/backfill.go index 76633df7d470..2fac6d7a40b7 100644 --- a/pkg/sql/backfill.go +++ b/pkg/sql/backfill.go @@ -799,7 +799,9 @@ func TruncateInterleavedIndexes( resumeAt := resume // Make a new txn just to drop this chunk. if err := db.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error { - rd := row.MakeDeleter(codec, table, nil /* requestedCols */) + rd := row.MakeDeleter( + codec, table, nil /* requestedCols */, &execCfg.Settings.SV, true, /* internal */ + ) td := tableDeleter{rd: rd, alloc: alloc} if err := td.init(ctx, txn, nil /* *tree.EvalContext */); err != nil { return err @@ -878,7 +880,10 @@ func (sc *SchemaChanger) truncateIndexes( if err != nil { return err } - rd := row.MakeDeleter(sc.execCfg.Codec, tableDesc, nil /* requestedCols */) + rd := row.MakeDeleter( + sc.execCfg.Codec, tableDesc, nil /* requestedCols */, &sc.settings.SV, + true, /* internal */ + ) td := tableDeleter{rd: rd, alloc: alloc} if err := td.init(ctx, txn, nil /* *tree.EvalContext */); err != nil { return err @@ -2473,7 +2478,10 @@ func indexTruncateInTxn( alloc := &rowenc.DatumAlloc{} var sp roachpb.Span for done := false; !done; done = sp.Key == nil { - rd := row.MakeDeleter(execCfg.Codec, tableDesc, nil /* requestedCols */) + rd := row.MakeDeleter( + execCfg.Codec, tableDesc, nil /* requestedCols */, &execCfg.Settings.SV, + evalCtx.SessionData.Internal, + ) td := tableDeleter{rd: rd, alloc: alloc} if err := td.init(ctx, txn, evalCtx); err != nil { return err diff --git a/pkg/sql/backfill/backfill.go b/pkg/sql/backfill/backfill.go index 4d690ce0df87..c06fdc09cd08 100644 --- a/pkg/sql/backfill/backfill.go +++ b/pkg/sql/backfill/backfill.go @@ -266,6 +266,8 @@ func (cb *ColumnBackfiller) RunColumnBackfillChunk( requestedCols, row.UpdaterOnlyColumns, &cb.alloc, + &cb.evalCtx.Settings.SV, + cb.evalCtx.SessionData.Internal, ) if err != nil { return roachpb.Key{}, err diff --git a/pkg/sql/create_table.go b/pkg/sql/create_table.go index f937cc61f7d2..1e36ec6d011c 100644 --- a/pkg/sql/create_table.go +++ b/pkg/sql/create_table.go @@ -455,7 +455,10 @@ func (n *createTableNode) startExec(params runParams) error { params.ExecCfg().Codec, desc.ImmutableCopy().(catalog.TableDescriptor), desc.PublicColumns(), - params.p.alloc) + params.p.alloc, + ¶ms.ExecCfg().Settings.SV, + params.p.SessionData().Internal, + ) if err != nil { return err } diff --git a/pkg/sql/gcjob/BUILD.bazel b/pkg/sql/gcjob/BUILD.bazel index 3ece5a8b119b..0c89a304d3f4 100644 --- a/pkg/sql/gcjob/BUILD.bazel +++ b/pkg/sql/gcjob/BUILD.bazel @@ -24,6 +24,7 @@ go_library( "//pkg/kv/kvserver/protectedts", "//pkg/kv/kvserver/protectedts/ptpb:ptpb_go_proto", "//pkg/roachpb:with-mocks", + "//pkg/settings", "//pkg/settings/cluster", "//pkg/sql", "//pkg/sql/catalog", diff --git a/pkg/sql/gcjob/table_garbage_collection.go b/pkg/sql/gcjob/table_garbage_collection.go index 40d30baf3aee..410da3c5073f 100644 --- a/pkg/sql/gcjob/table_garbage_collection.go +++ b/pkg/sql/gcjob/table_garbage_collection.go @@ -19,6 +19,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/kv/kvclient/kvcoord" "github.com/cockroachdb/cockroach/pkg/roachpb" + "github.com/cockroachdb/cockroach/pkg/settings" "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/catalog" "github.com/cockroachdb/cockroach/pkg/sql/catalog/catalogkv" @@ -65,7 +66,9 @@ func gcTables( } // First, delete all the table data. - if err := ClearTableData(ctx, execCfg.DB, execCfg.DistSender, execCfg.Codec, table); err != nil { + if err := ClearTableData( + ctx, execCfg.DB, execCfg.DistSender, execCfg.Codec, &execCfg.Settings.SV, table, + ); err != nil { return errors.Wrapf(err, "clearing data for table %d", table.GetID()) } @@ -86,6 +89,7 @@ func ClearTableData( db *kv.DB, distSender *kvcoord.DistSender, codec keys.SQLCodec, + sv *settings.Values, table catalog.TableDescriptor, ) error { // If DropTime isn't set, assume this drop request is from a version @@ -95,7 +99,7 @@ func ClearTableData( // cleaned up. if table.GetDropTime() == 0 || table.IsInterleaved() { log.Infof(ctx, "clearing data in chunks for table %d", table.GetID()) - return sql.ClearTableDataInChunks(ctx, db, codec, table, false /* traceKV */) + return sql.ClearTableDataInChunks(ctx, db, codec, sv, table, false /* traceKV */) } log.Infof(ctx, "clearing data for table %d", table.GetID()) diff --git a/pkg/sql/opt_exec_factory.go b/pkg/sql/opt_exec_factory.go index 95f6b21e98a7..cb6f35e475b9 100644 --- a/pkg/sql/opt_exec_factory.go +++ b/pkg/sql/opt_exec_factory.go @@ -1279,7 +1279,14 @@ func (ef *execFactory) ConstructInsert( // Create the table inserter, which does the bulk of the work. ri, err := row.MakeInserter( - ctx, ef.planner.txn, ef.planner.ExecCfg().Codec, tabDesc, cols, ef.planner.alloc, + ctx, + ef.planner.txn, + ef.planner.ExecCfg().Codec, + tabDesc, + cols, + ef.planner.alloc, + &ef.planner.ExecCfg().Settings.SV, + ef.planner.SessionData().Internal, ) if err != nil { return nil, err @@ -1345,7 +1352,14 @@ func (ef *execFactory) ConstructInsertFastPath( // Create the table inserter, which does the bulk of the work. ri, err := row.MakeInserter( - ctx, ef.planner.txn, ef.planner.ExecCfg().Codec, tabDesc, cols, ef.planner.alloc, + ctx, + ef.planner.txn, + ef.planner.ExecCfg().Codec, + tabDesc, + cols, + ef.planner.alloc, + &ef.planner.ExecCfg().Settings.SV, + ef.planner.SessionData().Internal, ) if err != nil { return nil, err @@ -1450,6 +1464,8 @@ func (ef *execFactory) ConstructUpdate( fetchCols, row.UpdaterDefault, ef.planner.alloc, + &ef.planner.ExecCfg().Settings.SV, + ef.planner.SessionData().Internal, ) if err != nil { return nil, err @@ -1550,6 +1566,8 @@ func (ef *execFactory) ConstructUpsert( tabDesc, insertCols, ef.planner.alloc, + &ef.planner.ExecCfg().Settings.SV, + ef.planner.SessionData().Internal, ) if err != nil { return nil, err @@ -1565,6 +1583,8 @@ func (ef *execFactory) ConstructUpsert( fetchCols, row.UpdaterDefault, ef.planner.alloc, + &ef.planner.ExecCfg().Settings.SV, + ef.planner.SessionData().Internal, ) if err != nil { return nil, err @@ -1636,7 +1656,13 @@ func (ef *execFactory) ConstructDelete( // the deleter derives the columns that need to be fetched. By contrast, the // CBO will have already determined the set of fetch columns, and passes // those sets into the deleter (which will basically be a no-op). - rd := row.MakeDeleter(ef.planner.ExecCfg().Codec, tabDesc, fetchCols) + rd := row.MakeDeleter( + ef.planner.ExecCfg().Codec, + tabDesc, + fetchCols, + &ef.planner.ExecCfg().Settings.SV, + ef.planner.SessionData().Internal, + ) // Now make a delete node. We use a pool. del := deleteNodePool.Get().(*deleteNode) diff --git a/pkg/sql/row/BUILD.bazel b/pkg/sql/row/BUILD.bazel index 177a7f6391b7..377e7be60338 100644 --- a/pkg/sql/row/BUILD.bazel +++ b/pkg/sql/row/BUILD.bazel @@ -25,8 +25,10 @@ go_library( "//pkg/jobs/jobspb", "//pkg/keys", "//pkg/kv", + "//pkg/kv/kvserver", "//pkg/kv/kvserver/concurrency/lock", "//pkg/roachpb:with-mocks", + "//pkg/settings", "//pkg/sql/catalog", "//pkg/sql/catalog/catalogkeys", "//pkg/sql/catalog/catalogkv", @@ -52,6 +54,7 @@ go_library( "//pkg/util/encoding", "//pkg/util/hlc", "//pkg/util/log", + "//pkg/util/log/eventpb", "//pkg/util/mon", "//pkg/util/sequence", "//pkg/util/syncutil", diff --git a/pkg/sql/row/deleter.go b/pkg/sql/row/deleter.go index 14fa7d560de2..de9da03a674a 100644 --- a/pkg/sql/row/deleter.go +++ b/pkg/sql/row/deleter.go @@ -16,6 +16,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/roachpb" + "github.com/cockroachdb/cockroach/pkg/settings" "github.com/cockroachdb/cockroach/pkg/sql/catalog" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/rowenc" @@ -41,7 +42,11 @@ type Deleter struct { // FetchCols; otherwise, all columns that are part of the key of any index // (either primary or secondary) are included in FetchCols. func MakeDeleter( - codec keys.SQLCodec, tableDesc catalog.TableDescriptor, requestedCols []catalog.Column, + codec keys.SQLCodec, + tableDesc catalog.TableDescriptor, + requestedCols []catalog.Column, + sv *settings.Values, + internal bool, ) Deleter { indexes := tableDesc.DeletableNonPrimaryIndexes() @@ -86,7 +91,7 @@ func MakeDeleter( } rd := Deleter{ - Helper: newRowHelper(codec, tableDesc, indexes), + Helper: newRowHelper(codec, tableDesc, indexes, sv, internal), FetchCols: fetchCols, FetchColIDtoRowIndex: fetchColIDtoRowIndex, } diff --git a/pkg/sql/row/helper.go b/pkg/sql/row/helper.go index 73d74594a313..d489d3670297 100644 --- a/pkg/sql/row/helper.go +++ b/pkg/sql/row/helper.go @@ -11,9 +11,14 @@ package row import ( + "context" + "fmt" "sort" "github.com/cockroachdb/cockroach/pkg/keys" + "github.com/cockroachdb/cockroach/pkg/kv/kvserver" + "github.com/cockroachdb/cockroach/pkg/roachpb" + "github.com/cockroachdb/cockroach/pkg/settings" "github.com/cockroachdb/cockroach/pkg/sql/catalog" "github.com/cockroachdb/cockroach/pkg/sql/catalog/catalogkeys" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" @@ -21,8 +26,39 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/util" "github.com/cockroachdb/cockroach/pkg/util/encoding" + "github.com/cockroachdb/cockroach/pkg/util/log" + "github.com/cockroachdb/cockroach/pkg/util/log/eventpb" ) +const ( + // maxRowSizeFloor is the lower bound for sql.mutations.max_row_size.{warn|error}. + maxRowSizeFloor = 1 << 10 + // maxRowSizeCeil is the upper bound for sql.mutations.max_row_size.{warn|error}. + maxRowSizeCeil = 512 << 20 +) + +var maxRowSizeWarn = settings.RegisterByteSizeSetting( + "sql.mutations.max_row_size.warn", + "maximum size of row (or column family if multiple column families are in use) that SQL can "+ + "write to the KV store, above which an event is logged to SQL_PERF or SQL_INTERNAL_PERF "+ + "(setting to 0 disables large row logging)", + kvserver.MaxCommandSizeDefault, + func(size int64) error { + if size != 0 && size < maxRowSizeFloor { + return fmt.Errorf( + "cannot set sql.mutations.max_row_size.warn to %v, must be 0 or >= %v", + size, maxRowSizeFloor, + ) + } else if size > maxRowSizeCeil { + return fmt.Errorf( + "cannot set sql.mutations.max_row_size.warn to %v, must be <= %v", + size, maxRowSizeCeil, + ) + } + return nil + }, +).WithPublic() + // rowHelper has the common methods for table row manipulations. type rowHelper struct { Codec keys.SQLCodec @@ -41,12 +77,19 @@ type rowHelper struct { primaryIndexKeyCols catalog.TableColSet primaryIndexValueCols catalog.TableColSet sortedColumnFamilies map[descpb.FamilyID][]descpb.ColumnID + + maxRowSizeWarn uint32 + internal bool } func newRowHelper( - codec keys.SQLCodec, desc catalog.TableDescriptor, indexes []catalog.Index, + codec keys.SQLCodec, + desc catalog.TableDescriptor, + indexes []catalog.Index, + sv *settings.Values, + internal bool, ) rowHelper { - rh := rowHelper{Codec: codec, TableDesc: desc, Indexes: indexes} + rh := rowHelper{Codec: codec, TableDesc: desc, Indexes: indexes, internal: internal} // Pre-compute the encoding directions of the index key values for // pretty-printing in traces. @@ -57,6 +100,8 @@ func newRowHelper( rh.secIndexValDirs[i] = catalogkeys.IndexKeyValDirs(rh.Indexes[i]) } + rh.maxRowSizeWarn = uint32(maxRowSizeWarn.Get(sv)) + return rh } @@ -169,3 +214,38 @@ func (rh *rowHelper) sortedColumnFamily(famID descpb.FamilyID) ([]descpb.ColumnI colIDs, ok := rh.sortedColumnFamilies[famID] return colIDs, ok } + +func (rh *rowHelper) checkRowSize( + ctx context.Context, + key *roachpb.Key, + value *roachpb.Value, + primIndex bool, + secIndex int, + family descpb.FamilyID, +) error { + size := uint32(len(*key)) + uint32(len(value.RawBytes)) + if rh.maxRowSizeWarn != 0 && size > rh.maxRowSizeWarn { + valDirs := rh.primIndexValDirs + index := rh.TableDesc.GetPrimaryIndex() + if !primIndex { + valDirs = rh.secIndexValDirs[secIndex] + index = rh.Indexes[secIndex] + } + details := eventpb.CommonLargeRowDetails{ + RowSize: size, + MaxRowSize: rh.maxRowSizeWarn, + TableID: uint32(rh.TableDesc.GetID()), + IndexID: uint32(index.GetID()), + FamilyID: uint32(family), + Key: keys.PrettyPrint(valDirs, *key), + } + var event eventpb.EventPayload + if rh.internal { + event = &eventpb.LargeRowInternal{CommonLargeRowDetails: details} + } else { + event = &eventpb.LargeRow{CommonLargeRowDetails: details} + } + log.StructuredEvent(ctx, event) + } + return nil +} diff --git a/pkg/sql/row/inserter.go b/pkg/sql/row/inserter.go index 0cde8dd743fd..f7bf6ef3159e 100644 --- a/pkg/sql/row/inserter.go +++ b/pkg/sql/row/inserter.go @@ -17,6 +17,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/roachpb" + "github.com/cockroachdb/cockroach/pkg/settings" "github.com/cockroachdb/cockroach/pkg/sql/catalog" "github.com/cockroachdb/cockroach/pkg/sql/rowenc" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" @@ -48,9 +49,12 @@ func MakeInserter( tableDesc catalog.TableDescriptor, insertCols []catalog.Column, alloc *rowenc.DatumAlloc, + sv *settings.Values, + internal bool, ) (Inserter, error) { ri := Inserter{ - Helper: newRowHelper(codec, tableDesc, tableDesc.WritableNonPrimaryIndexes()), + Helper: newRowHelper(codec, tableDesc, tableDesc.WritableNonPrimaryIndexes(), sv, internal), + InsertCols: insertCols, InsertColIDtoRowIndex: ColIDtoRowIndexFromCols(insertCols), marshaled: make([]roachpb.Value, len(insertCols)), @@ -175,6 +179,11 @@ func (ri *Inserter) InsertRow( putFn = insertInvertedPutFn for i := range secondaryIndexEntries { e := &secondaryIndexEntries[i] + if err := ri.Helper.checkRowSize( + ctx, &e.Key, &e.Value, false /* primIndex */, i, e.Family, + ); err != nil { + return err + } putFn(ctx, b, &e.Key, &e.Value, traceKV) } diff --git a/pkg/sql/row/row_converter.go b/pkg/sql/row/row_converter.go index 1a33e4961e11..3b110da0804d 100644 --- a/pkg/sql/row/row_converter.go +++ b/pkg/sql/row/row_converter.go @@ -347,6 +347,8 @@ func NewDatumRowConverter( tableDesc, cols, &rowenc.DatumAlloc{}, + &evalCtx.Settings.SV, + evalCtx.SessionData.Internal, ) if err != nil { return nil, errors.Wrap(err, "make row inserter") diff --git a/pkg/sql/row/updater.go b/pkg/sql/row/updater.go index 80f5dc5a76fe..153ce9f3e5b1 100644 --- a/pkg/sql/row/updater.go +++ b/pkg/sql/row/updater.go @@ -18,6 +18,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/kv" "github.com/cockroachdb/cockroach/pkg/roachpb" + "github.com/cockroachdb/cockroach/pkg/settings" "github.com/cockroachdb/cockroach/pkg/sql/catalog" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/rowenc" @@ -83,6 +84,8 @@ func MakeUpdater( requestedCols []catalog.Column, updateType rowUpdaterType, alloc *rowenc.DatumAlloc, + sv *settings.Values, + internal bool, ) (Updater, error) { if requestedCols == nil { return Updater{}, errors.AssertionFailedf("requestedCols is nil in MakeUpdater") @@ -157,12 +160,12 @@ func MakeUpdater( var deleteOnlyHelper *rowHelper if len(deleteOnlyIndexes) > 0 { - rh := newRowHelper(codec, tableDesc, deleteOnlyIndexes) + rh := newRowHelper(codec, tableDesc, deleteOnlyIndexes, sv, internal) deleteOnlyHelper = &rh } ru := Updater{ - Helper: newRowHelper(codec, tableDesc, includeIndexes), + Helper: newRowHelper(codec, tableDesc, includeIndexes, sv, internal), DeleteHelper: deleteOnlyHelper, FetchCols: requestedCols, FetchColIDtoRowIndex: ColIDtoRowIndexFromCols(requestedCols), @@ -177,9 +180,9 @@ func MakeUpdater( if primaryKeyColChange { // These fields are only used when the primary key is changing. var err error - ru.rd = MakeDeleter(codec, tableDesc, requestedCols) + ru.rd = MakeDeleter(codec, tableDesc, requestedCols, sv, internal) if ru.ri, err = MakeInserter( - ctx, txn, codec, tableDesc, requestedCols, alloc, + ctx, txn, codec, tableDesc, requestedCols, alloc, sv, internal, ); err != nil { return Updater{}, err } @@ -395,6 +398,11 @@ func (ru *Updater) UpdateRow( // insert that new k/v. for oldIdx < len(oldEntries) && newIdx < len(newEntries) { oldEntry, newEntry := &oldEntries[oldIdx], &newEntries[newIdx] + if err := ru.Helper.checkRowSize( + ctx, &newEntry.Key, &newEntry.Value, false /* primIndex */, i, newEntry.Family, + ); err != nil { + return nil, err + } if oldEntry.Family == newEntry.Family { // If the families are equal, then check if the keys have changed. If so, delete the old key. // Then, issue a CPut for the new value of the key if the value has changed. diff --git a/pkg/sql/row/writer.go b/pkg/sql/row/writer.go index caeba27a7090..4fb828578f13 100644 --- a/pkg/sql/row/writer.go +++ b/pkg/sql/row/writer.go @@ -154,6 +154,11 @@ func prepareInsertOrUpdateBatch( // We only output non-NULL values. Non-existent column keys are // considered NULL during scanning and the row sentinel ensures we know // the row exists. + if err := helper.checkRowSize( + ctx, kvKey, &marshaledValues[idx], true /* primIndex */, -1 /* secIndex */, family.ID, + ); err != nil { + return nil, err + } putFn(ctx, batch, kvKey, &marshaledValues[idx], traceKV) } @@ -204,6 +209,11 @@ func prepareInsertOrUpdateBatch( // a deep copy so rawValueBuf can be re-used by other calls to the // function. kvValue.SetTuple(rawValueBuf) + if err := helper.checkRowSize( + ctx, kvKey, kvValue, true /* primIndex */, -1 /* secIndex */, family.ID, + ); err != nil { + return nil, err + } putFn(ctx, batch, kvKey, kvValue, traceKV) } diff --git a/pkg/sql/truncate.go b/pkg/sql/truncate.go index dccc1556f297..225a27ab9ad7 100644 --- a/pkg/sql/truncate.go +++ b/pkg/sql/truncate.go @@ -436,6 +436,7 @@ func ClearTableDataInChunks( ctx context.Context, db *kv.DB, codec keys.SQLCodec, + sv *settings.Values, tableDesc catalog.TableDescriptor, traceKV bool, ) error { @@ -448,7 +449,7 @@ func ClearTableDataInChunks( log.VEventf(ctx, 2, "table %s truncate at row: %d, span: %s", tableDesc.GetName(), rowIdx, resume) } if err := db.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error { - rd := row.MakeDeleter(codec, tableDesc, nil /* requestedCols */) + rd := row.MakeDeleter(codec, tableDesc, nil /* requestedCols */, sv, true /* internal */) td := tableDeleter{rd: rd, alloc: alloc} if err := td.init(ctx, txn, nil /* *tree.EvalContext */); err != nil { return err diff --git a/pkg/util/log/eventpb/eventlog_channels_generated.go b/pkg/util/log/eventpb/eventlog_channels_generated.go index e4617ab296bf..ef174c103109 100644 --- a/pkg/util/log/eventpb/eventlog_channels_generated.go +++ b/pkg/util/log/eventpb/eventlog_channels_generated.go @@ -211,9 +211,15 @@ func (m *ClientConnectionStart) LoggingChannel() logpb.Channel { return logpb.Ch // LoggingChannel implements the EventPayload interface. func (m *ClientSessionEnd) LoggingChannel() logpb.Channel { return logpb.Channel_SESSIONS } +// LoggingChannel implements the EventPayload interface. +func (m *LargeRow) LoggingChannel() logpb.Channel { return logpb.Channel_SQL_PERF } + // LoggingChannel implements the EventPayload interface. func (m *SlowQuery) LoggingChannel() logpb.Channel { return logpb.Channel_SQL_PERF } +// LoggingChannel implements the EventPayload interface. +func (m *LargeRowInternal) LoggingChannel() logpb.Channel { return logpb.Channel_SQL_INTERNAL_PERF } + // LoggingChannel implements the EventPayload interface. func (m *SlowQueryInternal) LoggingChannel() logpb.Channel { return logpb.Channel_SQL_INTERNAL_PERF } diff --git a/pkg/util/log/eventpb/json_encode_generated.go b/pkg/util/log/eventpb/json_encode_generated.go index 78af42147979..848caa875b3c 100644 --- a/pkg/util/log/eventpb/json_encode_generated.go +++ b/pkg/util/log/eventpb/json_encode_generated.go @@ -1075,6 +1075,69 @@ func (m *CommonJobEventDetails) AppendJSONFields(printComma bool, b redact.Redac return printComma, b } +// AppendJSONFields implements the EventPayload interface. +func (m *CommonLargeRowDetails) AppendJSONFields(printComma bool, b redact.RedactableBytes) (bool, redact.RedactableBytes) { + + if m.RowSize != 0 { + if printComma { + b = append(b, ',') + } + printComma = true + b = append(b, "\"RowSize\":"...) + b = strconv.AppendUint(b, uint64(m.RowSize), 10) + } + + if m.MaxRowSize != 0 { + if printComma { + b = append(b, ',') + } + printComma = true + b = append(b, "\"MaxRowSize\":"...) + b = strconv.AppendUint(b, uint64(m.MaxRowSize), 10) + } + + if m.TableID != 0 { + if printComma { + b = append(b, ',') + } + printComma = true + b = append(b, "\"TableID\":"...) + b = strconv.AppendUint(b, uint64(m.TableID), 10) + } + + if m.IndexID != 0 { + if printComma { + b = append(b, ',') + } + printComma = true + b = append(b, "\"IndexID\":"...) + b = strconv.AppendUint(b, uint64(m.IndexID), 10) + } + + if m.FamilyID != 0 { + if printComma { + b = append(b, ',') + } + printComma = true + b = append(b, "\"FamilyID\":"...) + b = strconv.AppendUint(b, uint64(m.FamilyID), 10) + } + + if m.Key != "" { + if printComma { + b = append(b, ',') + } + printComma = true + b = append(b, "\"Key\":\""...) + b = append(b, redact.StartMarker()...) + b = redact.RedactableBytes(jsonbytes.EncodeString([]byte(b), string(redact.EscapeMarkers([]byte(m.Key))))) + b = append(b, redact.EndMarker()...) + b = append(b, '"') + } + + return printComma, b +} + // AppendJSONFields implements the EventPayload interface. func (m *CommonNodeDecommissionDetails) AppendJSONFields(printComma bool, b redact.RedactableBytes) (bool, redact.RedactableBytes) { @@ -2119,6 +2182,26 @@ func (m *Import) AppendJSONFields(printComma bool, b redact.RedactableBytes) (bo return printComma, b } +// AppendJSONFields implements the EventPayload interface. +func (m *LargeRow) AppendJSONFields(printComma bool, b redact.RedactableBytes) (bool, redact.RedactableBytes) { + + printComma, b = m.CommonEventDetails.AppendJSONFields(printComma, b) + + printComma, b = m.CommonLargeRowDetails.AppendJSONFields(printComma, b) + + return printComma, b +} + +// AppendJSONFields implements the EventPayload interface. +func (m *LargeRowInternal) AppendJSONFields(printComma bool, b redact.RedactableBytes) (bool, redact.RedactableBytes) { + + printComma, b = m.CommonEventDetails.AppendJSONFields(printComma, b) + + printComma, b = m.CommonLargeRowDetails.AppendJSONFields(printComma, b) + + return printComma, b +} + // AppendJSONFields implements the EventPayload interface. func (m *NodeDecommissioned) AppendJSONFields(printComma bool, b redact.RedactableBytes) (bool, redact.RedactableBytes) { diff --git a/pkg/util/log/eventpb/sql_audit_events.pb.go b/pkg/util/log/eventpb/sql_audit_events.pb.go index 90b2553dc6cd..005db930ef24 100644 --- a/pkg/util/log/eventpb/sql_audit_events.pb.go +++ b/pkg/util/log/eventpb/sql_audit_events.pb.go @@ -198,6 +198,83 @@ func (m *SlowQuery) XXX_DiscardUnknown() { var xxx_messageInfo_SlowQuery proto.InternalMessageInfo +// CommonLargeRowDetails contains the fields common to both LargeRow and +// LargeRowInternal events. +type CommonLargeRowDetails struct { + RowSize uint32 `protobuf:"varint,1,opt,name=row_size,json=rowSize,proto3" json:",omitempty"` + MaxRowSize uint32 `protobuf:"varint,2,opt,name=max_row_size,json=maxRowSize,proto3" json:",omitempty"` + TableID uint32 `protobuf:"varint,3,opt,name=table_id,json=tableId,proto3" json:",omitempty"` + IndexID uint32 `protobuf:"varint,4,opt,name=index_id,json=indexId,proto3" json:",omitempty"` + FamilyID uint32 `protobuf:"varint,5,opt,name=family_id,json=familyId,proto3" json:",omitempty"` + Key string `protobuf:"bytes,6,opt,name=key,proto3" json:",omitempty"` +} + +func (m *CommonLargeRowDetails) Reset() { *m = CommonLargeRowDetails{} } +func (m *CommonLargeRowDetails) String() string { return proto.CompactTextString(m) } +func (*CommonLargeRowDetails) ProtoMessage() {} +func (*CommonLargeRowDetails) Descriptor() ([]byte, []int) { + return fileDescriptor_b7a82d5e93041841, []int{4} +} +func (m *CommonLargeRowDetails) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CommonLargeRowDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *CommonLargeRowDetails) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommonLargeRowDetails.Merge(m, src) +} +func (m *CommonLargeRowDetails) XXX_Size() int { + return m.Size() +} +func (m *CommonLargeRowDetails) XXX_DiscardUnknown() { + xxx_messageInfo_CommonLargeRowDetails.DiscardUnknown(m) +} + +var xxx_messageInfo_CommonLargeRowDetails proto.InternalMessageInfo + +// LargeRow is recorded when a row larger than cluster setting +// `sql.mutations.max_row_size.warn` is added to the database. A single +// statement could cause multiple LargeRow events to be emitted. +type LargeRow struct { + CommonEventDetails `protobuf:"bytes,1,opt,name=common,proto3,embedded=common" json:""` + CommonLargeRowDetails `protobuf:"bytes,2,opt,name=row,proto3,embedded=row" json:""` +} + +func (m *LargeRow) Reset() { *m = LargeRow{} } +func (m *LargeRow) String() string { return proto.CompactTextString(m) } +func (*LargeRow) ProtoMessage() {} +func (*LargeRow) Descriptor() ([]byte, []int) { + return fileDescriptor_b7a82d5e93041841, []int{5} +} +func (m *LargeRow) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LargeRow) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *LargeRow) XXX_Merge(src proto.Message) { + xxx_messageInfo_LargeRow.Merge(m, src) +} +func (m *LargeRow) XXX_Size() int { + return m.Size() +} +func (m *LargeRow) XXX_DiscardUnknown() { + xxx_messageInfo_LargeRow.DiscardUnknown(m) +} + +var xxx_messageInfo_LargeRow proto.InternalMessageInfo + // SlowQueryInternal is recorded when a query triggers the "slow query" condition, // and the cluster setting `sql.log.slow_query.internal_queries.enabled` is // set. @@ -213,7 +290,7 @@ func (m *SlowQueryInternal) Reset() { *m = SlowQueryInternal{} } func (m *SlowQueryInternal) String() string { return proto.CompactTextString(m) } func (*SlowQueryInternal) ProtoMessage() {} func (*SlowQueryInternal) Descriptor() ([]byte, []int) { - return fileDescriptor_b7a82d5e93041841, []int{4} + return fileDescriptor_b7a82d5e93041841, []int{6} } func (m *SlowQueryInternal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -238,6 +315,44 @@ func (m *SlowQueryInternal) XXX_DiscardUnknown() { var xxx_messageInfo_SlowQueryInternal proto.InternalMessageInfo +// LargeRowInternal is recorded when a row larger than cluster setting +// `sql.mutations.max_row_size.warn` is added to the database by an internal +// query. A single internal query could cause multiple LargeRowInternal events +// to be emitted. +type LargeRowInternal struct { + CommonEventDetails `protobuf:"bytes,1,opt,name=common,proto3,embedded=common" json:""` + CommonLargeRowDetails `protobuf:"bytes,2,opt,name=row,proto3,embedded=row" json:""` +} + +func (m *LargeRowInternal) Reset() { *m = LargeRowInternal{} } +func (m *LargeRowInternal) String() string { return proto.CompactTextString(m) } +func (*LargeRowInternal) ProtoMessage() {} +func (*LargeRowInternal) Descriptor() ([]byte, []int) { + return fileDescriptor_b7a82d5e93041841, []int{7} +} +func (m *LargeRowInternal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LargeRowInternal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *LargeRowInternal) XXX_Merge(src proto.Message) { + xxx_messageInfo_LargeRowInternal.Merge(m, src) +} +func (m *LargeRowInternal) XXX_Size() int { + return m.Size() +} +func (m *LargeRowInternal) XXX_DiscardUnknown() { + xxx_messageInfo_LargeRowInternal.DiscardUnknown(m) +} + +var xxx_messageInfo_LargeRowInternal proto.InternalMessageInfo + // QueryExecute is recorded when a query is executed, // and the cluster setting `sql.trace.log_statement_execute` is set. type QueryExecute struct { @@ -250,7 +365,7 @@ func (m *QueryExecute) Reset() { *m = QueryExecute{} } func (m *QueryExecute) String() string { return proto.CompactTextString(m) } func (*QueryExecute) ProtoMessage() {} func (*QueryExecute) Descriptor() ([]byte, []int) { - return fileDescriptor_b7a82d5e93041841, []int{5} + return fileDescriptor_b7a82d5e93041841, []int{8} } func (m *QueryExecute) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -280,7 +395,10 @@ func init() { proto.RegisterType((*SensitiveTableAccess)(nil), "cockroach.util.log.eventpb.SensitiveTableAccess") proto.RegisterType((*AdminQuery)(nil), "cockroach.util.log.eventpb.AdminQuery") proto.RegisterType((*SlowQuery)(nil), "cockroach.util.log.eventpb.SlowQuery") + proto.RegisterType((*CommonLargeRowDetails)(nil), "cockroach.util.log.eventpb.CommonLargeRowDetails") + proto.RegisterType((*LargeRow)(nil), "cockroach.util.log.eventpb.LargeRow") proto.RegisterType((*SlowQueryInternal)(nil), "cockroach.util.log.eventpb.SlowQueryInternal") + proto.RegisterType((*LargeRowInternal)(nil), "cockroach.util.log.eventpb.LargeRowInternal") proto.RegisterType((*QueryExecute)(nil), "cockroach.util.log.eventpb.QueryExecute") } @@ -289,46 +407,56 @@ func init() { } var fileDescriptor_b7a82d5e93041841 = []byte{ - // 612 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0xcf, 0x4f, 0x13, 0x4f, - 0x18, 0xc6, 0xbb, 0x2d, 0x3f, 0xda, 0xb7, 0xf0, 0xfd, 0xc6, 0x09, 0x26, 0x1b, 0x12, 0xb7, 0xcd, - 0x5e, 0x28, 0x89, 0x6e, 0x15, 0x12, 0x0f, 0xde, 0x28, 0x90, 0x48, 0x82, 0x9a, 0xfe, 0x38, 0x79, - 0xd9, 0x0c, 0xd3, 0xd7, 0xba, 0x71, 0x76, 0x06, 0x76, 0x66, 0x61, 0xf9, 0x0f, 0x34, 0x7a, 0xe0, - 0xcf, 0xe2, 0xc8, 0x91, 0x53, 0xa3, 0xe5, 0xc6, 0xd1, 0xab, 0x17, 0x33, 0xb3, 0x05, 0x95, 0xda, - 0x88, 0x67, 0xbc, 0xf5, 0xc7, 0xf3, 0x7c, 0xde, 0x9d, 0x67, 0x9e, 0x37, 0x0b, 0x2b, 0xa9, 0x8e, - 0x78, 0x93, 0xcb, 0x41, 0x13, 0x0f, 0x51, 0xe8, 0xfd, 0xbd, 0xa6, 0x3a, 0xe0, 0x21, 0x4d, 0xfb, - 0x91,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90, 0x96, 0x65, 0x8a, - 0x93, 0xdf, 0x98, 0xa0, 0x31, 0x4e, 0x2b, 0x8e, 0x55, 0xbc, 0xa4, 0x31, 0x92, 0xe7, 0x50, 0xa5, - 0x36, 0xb5, 0x7c, 0x57, 0x66, 0xff, 0x6e, 0x57, 0x20, 0xf7, 0x9a, 0x6d, 0xf1, 0x3f, 0x14, 0x01, - 0x36, 0xfa, 0x71, 0x24, 0xda, 0x29, 0x26, 0xc7, 0x77, 0xfa, 0x12, 0xfc, 0xf7, 0x45, 0xa8, 0x74, - 0xb9, 0x3c, 0xfa, 0x17, 0x85, 0x7f, 0x52, 0x84, 0x7b, 0xd7, 0x51, 0xec, 0x98, 0xc5, 0x15, 0x94, - 0xdf, 0xed, 0x48, 0x3e, 0x16, 0x61, 0xc1, 0xc6, 0x61, 0x84, 0xa9, 0xc6, 0x3b, 0x9d, 0x46, 0x6b, - 0xf5, 0xf4, 0x8b, 0x57, 0x38, 0x1d, 0x79, 0xce, 0xd9, 0xc8, 0x73, 0xce, 0x47, 0x9e, 0xf3, 0x79, - 0xe4, 0x39, 0x27, 0x17, 0x5e, 0xe1, 0xec, 0xc2, 0x2b, 0x9c, 0x5f, 0x78, 0x85, 0xd7, 0xf3, 0x63, - 0xe6, 0xde, 0x9c, 0x7d, 0xed, 0xaf, 0x7f, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x35, 0xbf, 0x4c, 0x0f, - 0x72, 0x08, 0x00, 0x00, + // 777 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x3d, 0x6f, 0xd3, 0x50, + 0x14, 0x8d, 0x9d, 0xb6, 0x71, 0x6e, 0x5a, 0x3e, 0xac, 0x56, 0x32, 0x91, 0x70, 0x22, 0x2f, 0x4d, + 0x25, 0x48, 0x4a, 0x8b, 0x40, 0x62, 0x6b, 0xda, 0x22, 0x22, 0x15, 0x50, 0x3e, 0x26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a4, 0x36, 0x56, 0x97, 0x40, 0x21, 0xa1, 0x67, 0xfa, 0x34, 0x0a, 0x34, + 0xb9, 0x2c, 0x55, 0xa6, 0xea, 0xb7, 0x7e, 0x17, 0x69, 0xe5, 0x48, 0xe8, 0xb5, 0x68, 0x14, 0xa8, + 0xaf, 0x41, 0x09, 0xf6, 0xdd, 0x80, 0x21, 0x86, 0xb5, 0xac, 0xa8, 0xb7, 0x3a, 0xe8, 0x97, 0x94, + 0x76, 0x73, 0xab, 0xdd, 0x59, 0xeb, 0x6c, 0x5e, 0xb9, 0xf6, 0x48, 0x44, 0x7d, 0x08, 0x80, 0x7d, + 0x9f, 0xfa, 0x26, 0xc3, 0x31, 0xd3, 0xa6, 0x84, 0xe4, 0x78, 0xf5, 0xbc, 0x40, 0x74, 0x70, 0xcc, + 0xd4, 0x32, 0x64, 0x51, 0x17, 0x6b, 0xd3, 0x65, 0xa9, 0x22, 0xa7, 0x70, 0xfc, 0x95, 0x5a, 0x83, + 0x82, 0x68, 0x06, 0x33, 0xdf, 0xc1, 0x81, 0x36, 0x53, 0x96, 0x2a, 0x73, 0x29, 0x24, 0xf0, 0x7e, + 0x12, 0x84, 0xfa, 0x04, 0x6e, 0xef, 0x84, 0xae, 0x6b, 0x32, 0xb4, 0xed, 0x62, 0x33, 0xb0, 0x10, + 0xd1, 0x72, 0x65, 0xa9, 0xa2, 0xa4, 0x48, 0x73, 0x1c, 0xd6, 0xe1, 0xa8, 0xb6, 0x85, 0xc8, 0x05, + 0xcf, 0x21, 0x36, 0x8e, 0x13, 0x9e, 0x32, 0x99, 0xd7, 0xe0, 0x28, 0xc1, 0xab, 0x41, 0x81, 0xc5, + 0xc4, 0xb4, 0x68, 0x48, 0x18, 0xf6, 0xb5, 0xfc, 0xe5, 0x3f, 0x90, 0xc5, 0x64, 0x3d, 0x41, 0x18, + 0x1f, 0xb3, 0x30, 0xdf, 0x1e, 0xcd, 0x4e, 0xd4, 0x5f, 0xb3, 0x2c, 0x1c, 0x04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, 0x00, } func (m *CommonSQLExecDetails) Marshal() (dAtA []byte, err error) { @@ -589,6 +717,104 @@ func (m *SlowQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *CommonLargeRowDetails) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CommonLargeRowDetails) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommonLargeRowDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintSqlAuditEvents(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x32 + } + if m.FamilyID != 0 { + i = encodeVarintSqlAuditEvents(dAtA, i, uint64(m.FamilyID)) + i-- + dAtA[i] = 0x28 + } + if m.IndexID != 0 { + i = encodeVarintSqlAuditEvents(dAtA, i, uint64(m.IndexID)) + i-- + dAtA[i] = 0x20 + } + if m.TableID != 0 { + i = encodeVarintSqlAuditEvents(dAtA, i, uint64(m.TableID)) + i-- + dAtA[i] = 0x18 + } + if m.MaxRowSize != 0 { + i = encodeVarintSqlAuditEvents(dAtA, i, uint64(m.MaxRowSize)) + i-- + dAtA[i] = 0x10 + } + if m.RowSize != 0 { + i = encodeVarintSqlAuditEvents(dAtA, i, uint64(m.RowSize)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *LargeRow) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LargeRow) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LargeRow) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.CommonLargeRowDetails.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSqlAuditEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.CommonEventDetails.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSqlAuditEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *SlowQueryInternal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -642,6 +868,49 @@ func (m *SlowQueryInternal) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *LargeRowInternal) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LargeRowInternal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LargeRowInternal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.CommonLargeRowDetails.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSqlAuditEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.CommonEventDetails.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSqlAuditEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *QueryExecute) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -798,6 +1067,47 @@ func (m *SlowQuery) Size() (n int) { return n } +func (m *CommonLargeRowDetails) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RowSize != 0 { + n += 1 + sovSqlAuditEvents(uint64(m.RowSize)) + } + if m.MaxRowSize != 0 { + n += 1 + sovSqlAuditEvents(uint64(m.MaxRowSize)) + } + if m.TableID != 0 { + n += 1 + sovSqlAuditEvents(uint64(m.TableID)) + } + if m.IndexID != 0 { + n += 1 + sovSqlAuditEvents(uint64(m.IndexID)) + } + if m.FamilyID != 0 { + n += 1 + sovSqlAuditEvents(uint64(m.FamilyID)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovSqlAuditEvents(uint64(l)) + } + return n +} + +func (m *LargeRow) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.CommonEventDetails.Size() + n += 1 + l + sovSqlAuditEvents(uint64(l)) + l = m.CommonLargeRowDetails.Size() + n += 1 + l + sovSqlAuditEvents(uint64(l)) + return n +} + func (m *SlowQueryInternal) Size() (n int) { if m == nil { return 0 @@ -813,6 +1123,19 @@ func (m *SlowQueryInternal) Size() (n int) { return n } +func (m *LargeRowInternal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.CommonEventDetails.Size() + n += 1 + l + sovSqlAuditEvents(uint64(l)) + l = m.CommonLargeRowDetails.Size() + n += 1 + l + sovSqlAuditEvents(uint64(l)) + return n +} + func (m *QueryExecute) Size() (n int) { if m == nil { return 0 @@ -1599,7 +1922,7 @@ func (m *SlowQuery) Unmarshal(dAtA []byte) error { } return nil } -func (m *SlowQueryInternal) Unmarshal(dAtA []byte) error { +func (m *CommonLargeRowDetails) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1622,17 +1945,17 @@ func (m *SlowQueryInternal) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: SlowQueryInternal: wiretype end group for non-group") + return fmt.Errorf("proto: CommonLargeRowDetails: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: SlowQueryInternal: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: CommonLargeRowDetails: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommonEventDetails", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RowSize", wireType) } - var msglen int + m.RowSize = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowSqlAuditEvents @@ -1642,30 +1965,16 @@ func (m *SlowQueryInternal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.RowSize |= uint32(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthSqlAuditEvents - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSqlAuditEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CommonEventDetails.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommonSQLEventDetails", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxRowSize", wireType) } - var msglen int + m.MaxRowSize = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowSqlAuditEvents @@ -1675,30 +1984,16 @@ func (m *SlowQueryInternal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.MaxRowSize |= uint32(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthSqlAuditEvents - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSqlAuditEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CommonSQLEventDetails.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommonSQLExecDetails", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TableID", wireType) } - var msglen int + m.TableID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowSqlAuditEvents @@ -1708,12 +2003,333 @@ func (m *SlowQueryInternal) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.TableID |= uint32(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IndexID", wireType) + } + m.IndexID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.IndexID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FamilyID", wireType) + } + m.FamilyID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FamilyID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSqlAuditEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSqlAuditEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSqlAuditEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSqlAuditEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LargeRow) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LargeRow: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LargeRow: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommonEventDetails", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSqlAuditEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSqlAuditEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CommonEventDetails.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommonLargeRowDetails", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSqlAuditEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSqlAuditEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CommonLargeRowDetails.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSqlAuditEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSqlAuditEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SlowQueryInternal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SlowQueryInternal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SlowQueryInternal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommonEventDetails", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSqlAuditEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSqlAuditEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CommonEventDetails.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommonSQLEventDetails", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSqlAuditEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSqlAuditEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CommonSQLEventDetails.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommonSQLExecDetails", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { return ErrInvalidLengthSqlAuditEvents } postIndex := iNdEx + msglen @@ -1748,6 +2364,122 @@ func (m *SlowQueryInternal) Unmarshal(dAtA []byte) error { } return nil } +func (m *LargeRowInternal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LargeRowInternal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LargeRowInternal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommonEventDetails", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSqlAuditEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSqlAuditEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CommonEventDetails.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommonLargeRowDetails", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSqlAuditEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSqlAuditEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSqlAuditEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CommonLargeRowDetails.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSqlAuditEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSqlAuditEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryExecute) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/pkg/util/log/eventpb/sql_audit_events.proto b/pkg/util/log/eventpb/sql_audit_events.proto index 8cf8981c6b55..b770694ddd0f 100644 --- a/pkg/util/log/eventpb/sql_audit_events.proto +++ b/pkg/util/log/eventpb/sql_audit_events.proto @@ -101,6 +101,25 @@ message SlowQuery { CommonSQLExecDetails exec = 3 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "", (gogoproto.embed) = true]; } +// CommonLargeRowDetails contains the fields common to both LargeRow and +// LargeRowInternal events. +message CommonLargeRowDetails { + uint32 row_size = 1 [(gogoproto.jsontag) = ",omitempty"]; + uint32 max_row_size = 2 [(gogoproto.jsontag) = ",omitempty"]; + uint32 table_id = 3 [(gogoproto.customname) = "TableID", (gogoproto.jsontag) = ",omitempty"]; + uint32 index_id = 4 [(gogoproto.customname) = "IndexID", (gogoproto.jsontag) = ",omitempty"]; + uint32 family_id = 5 [(gogoproto.customname) = "FamilyID", (gogoproto.jsontag) = ",omitempty"]; + string key = 6 [(gogoproto.jsontag) = ",omitempty"]; +} + +// LargeRow is recorded when a row larger than cluster setting +// `sql.mutations.max_row_size.warn` is added to the database. A single +// statement could cause multiple LargeRow events to be emitted. +message LargeRow { + CommonEventDetails common = 1 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "", (gogoproto.embed) = true]; + CommonLargeRowDetails row = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "", (gogoproto.embed) = true]; +} + // Category: SQL Slow Query Log (Internal) // Channel: SQL_INTERNAL_PERF // @@ -123,6 +142,15 @@ message SlowQueryInternal { CommonSQLExecDetails exec = 3 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "", (gogoproto.embed) = true]; } +// LargeRowInternal is recorded when a row larger than cluster setting +// `sql.mutations.max_row_size.warn` is added to the database by an internal +// query. A single internal query could cause multiple LargeRowInternal events +// to be emitted. +message LargeRowInternal { + CommonEventDetails common = 1 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "", (gogoproto.embed) = true]; + CommonLargeRowDetails row = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "", (gogoproto.embed) = true]; +} + // Category: SQL Execution Log // Channel: SQL_EXEC //