Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
82925: batcheval: allow writing tombstones in `AddSSTable` r=aliher1911 a=erikgrinaker

This patch allows writing MVCC point tombstones in `AddSSTable`, which
will be needed by cluster-to-cluster replication. Previously, SSTs
containing tombstones could error or be silently accepted. The version
gate `AddSSTableTombstones` has been added to allow clients to rely on
this behavior.

Note that `AddSSTable` has never made any attempt at correctly
calculating `MVCCStats.GCBytesAge` when shadowing existing data, and
this patch does not attempt to either. This will be addressed later.

Resolves cockroachdb#82922.
Touches cockroachdb#82920.

Release note: None

82952: builtins: add pg_backend_pid() r=otan a=rafiss

fixes cockroachdb#82564

Release note (sql change): Updated the pg_backend_pid() builtin function
so it matches with the data in the query cancellation key created during
session initialization. The function is just for compatibility, and it
does not return a real process ID.

Co-authored-by: Erik Grinaker <[email protected]>
Co-authored-by: Rafi Shamim <[email protected]>
  • Loading branch information
3 people committed Jun 16, 2022
3 parents 1634866 + 04be3bc + 343335a commit 277921b
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 94 deletions.
2 changes: 1 addition & 1 deletion docs/generated/settings/settings-for-tenants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,4 @@ trace.jaeger.agent string the address of a Jaeger agent to receive traces using
trace.opentelemetry.collector string address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as <host>:<port>. If no port is specified, 4317 will be used.
trace.span_registry.enabled boolean true if set, ongoing traces can be seen at https://<ui>/#/debug/tracez
trace.zipkin.collector string the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.
version version 22.1-18 set the active cluster version in the format '<major>.<minor>'
version version 22.1-20 set the active cluster version in the format '<major>.<minor>'
2 changes: 1 addition & 1 deletion docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,6 @@
<tr><td><code>trace.opentelemetry.collector</code></td><td>string</td><td><code></code></td><td>address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as <host>:<port>. If no port is specified, 4317 will be used.</td></tr>
<tr><td><code>trace.span_registry.enabled</code></td><td>boolean</td><td><code>true</code></td><td>if set, ongoing traces can be seen at https://<ui>/#/debug/tracez</td></tr>
<tr><td><code>trace.zipkin.collector</code></td><td>string</td><td><code></code></td><td>the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>22.1-18</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>22.1-20</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
</tbody>
</table>
2 changes: 2 additions & 0 deletions docs/generated/sql/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3419,6 +3419,8 @@ A write probe will effectively probe reads as well.</p>
</span></td></tr>
<tr><td><a name="oid"></a><code>oid(int: <a href="int.html">int</a>) &rarr; oid</code></td><td><span class="funcdesc"><p>Converts an integer to an OID.</p>
</span></td></tr>
<tr><td><a name="pg_backend_pid"></a><code>pg_backend_pid() &rarr; <a href="int.html">int</a></code></td><td><span class="funcdesc"><p>Returns a numerical ID attached to this session. This ID is part of the query cancellation key used by the wire protocol. This function was only added for compatibility, and unlike in Postgres, thereturned value does not correspond to a real process ID.</p>
</span></td></tr>
<tr><td><a name="pg_collation_for"></a><code>pg_collation_for(str: anyelement) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns the collation of the argument</p>
</span></td></tr>
<tr><td><a name="pg_column_is_updatable"></a><code>pg_column_is_updatable(reloid: oid, attnum: int2, include_triggers: <a href="bool.html">bool</a>) &rarr; <a href="bool.html">bool</a></code></td><td><span class="funcdesc"><p>Returns whether the given column can be updated.</p>
Expand Down
7 changes: 7 additions & 0 deletions pkg/clusterversion/cockroach_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ const (
// probabilistically collects stmt bundles, controlled by the user provided
// sampling rate.
SampledStmtDiagReqs
// AddSSTableTombstones allows writing MVCC point tombstones via AddSSTable.
// Previously, SSTs containing these could error.
AddSSTableTombstones

// *************************************************
// Step (1): Add new versions here.
Expand Down Expand Up @@ -666,6 +669,10 @@ var versionsSingleton = keyedVersions{
Key: SampledStmtDiagReqs,
Version: roachpb.Version{Major: 22, Minor: 1, Internal: 18},
},
{
Key: AddSSTableTombstones,
Version: roachpb.Version{Major: 22, Minor: 1, Internal: 20},
},

// *************************************************
// Step (2): Add new versions here.
Expand Down
5 changes: 3 additions & 2 deletions pkg/clusterversion/key_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 4 additions & 15 deletions pkg/kv/kvserver/batcheval/cmd_add_sstable.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,32 +428,21 @@ func assertSSTContents(sst []byte, sstTimestamp hlc.Timestamp, stats *enginepb.M
defer iter.Close()

// Check SST KV pairs.
iter.SeekGE(storage.MVCCKey{Key: keys.MinKey})
for {
ok, err := iter.Valid()
if err != nil {
for iter.SeekGE(storage.MVCCKey{Key: keys.MinKey}); ; iter.Next() {
if ok, err := iter.Valid(); err != nil {
return err
}
if !ok {
} else if !ok {
break
}

key, valueRaw := iter.UnsafeKey(), iter.UnsafeValue()
value, err := storage.DecodeMVCCValue(valueRaw)
if err != nil {
return err
}
key := iter.UnsafeKey()
if key.Timestamp.IsEmpty() {
return errors.AssertionFailedf("SST contains inline value or intent for key %s", key)
}
if value.IsTombstone() {
return errors.AssertionFailedf("SST contains tombstone for key %s", key)
}
if sstTimestamp.IsSet() && key.Timestamp != sstTimestamp {
return errors.AssertionFailedf("SST has unexpected timestamp %s (expected %s) for key %s",
key.Timestamp, sstTimestamp, key.Key)
}
iter.Next()
}

// Compare statistics with those passed by client. We calculate them at the
Expand Down
Loading

0 comments on commit 277921b

Please sign in to comment.