Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
117798: sql: fix float to integer casting r=mgartner a=da-ket

Previously, casting a float value to an integer simply truncates the float. This commit fixes that by rounding the float value to the nearest integer, rounding ties to even, as in postgres.

Epic: None
Fixes: #112515

Release note (bug fix): A bug has been fixed where casts of floats to integers
truncated the value. These casts now round a float to the nearest integer,
rounding ties to even integers.

118489: concurrency: add basic deadlock tests involving shared locks r=arulajmani a=arulajmani

Informs #109634

Release note: None

118640: sql: fix usages of internal executor to delegate from user transaction r=rafiss a=rafiss

These commits fix a few usages of the internal executor to use the new interface which delegates to an internal executor that shares the outer txn's state.

For ease of review, the testing for this is in a separate PR (where the bugs were discovered): #107990

informs #100178

118653: sql: keep track of per-stmt read committed retries r=rafiss a=rafiss

This change makes it possible to view automatic retries performed under read committed txns in the DB Console.

fixes #113986
Release note: None

118657: server/status: silence missing CPU cgroup error r=nvanbenschoten a=nvanbenschoten

Fixes #111648.

This commit eliminates log spam when a CPU cgroup is not configured for the cockroach process. This is a supported deployment mode, but since `v22.2.11`/`v23.1.3`/`v23.2.0` (df55958), we've been spamming the logs with "unable to get CPU capacity" errors every 10 seconds when running outside of a CPU cgroup.

I considered reducing the severity of the log message from ERROR to INFO, but even that seemed loud for a log message every 10s in a supported deployment mode. For now, we remove the log message.

Release note (bug fix): Cockroach will no longer spam the logs with "unable to get CPU capacity" errors every 10 seconds when running outside of a CPU cgroup.

118660: server: disambiguate duplicated column names in /v2/sql endpoint r=rafiss a=rafiss

Previously, results that had the same column name would clobber each other in the response of this endpoint, since JSON does not allow duplicate key names. This is fixed by adding a suffix when column names are duplicated.

No release note since this endpoint is for internal use.

fixes #116851
Release note: None

Co-authored-by: da-ket <daket.duet@gmail.com>
Co-authored-by: Arul Ajmani <arulajmani@gmail.com>
Co-authored-by: Rafi Shamim <rafi@cockroachlabs.com>
Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
  • Loading branch information
5 people committed Feb 2, 2024
7 parents c0dc3be + 66be939 + 9985973 + f9e0d48 + aeb1649 + 153fd8f + adb935e commit 9434801
Show file tree
Hide file tree
Showing 31 changed files with 595 additions and 51 deletions.
3 changes: 1 addition & 2 deletions pkg/ccl/logictestccl/testdata/logic_test/udf_plpgsql
Original file line number Diff line number Diff line change
Expand Up @@ -2405,7 +2405,6 @@ subtest plpgsql_types
# If an assignment cast is available, the cast is performed automatically.
#
# float -> int
# TODO(112515): the float value is incorrectly truncated instead of rounded.
statement ok
DROP FUNCTION F();
CREATE OR REPLACE FUNCTION f() RETURNS INT AS $$
Expand All @@ -2417,7 +2416,7 @@ $$ LANGUAGE PLpgSQL;
query I
SELECT f();
----
105
106

# decimal -> int
statement ok
Expand Down
5 changes: 3 additions & 2 deletions pkg/ccl/serverccl/testdata/api_v2_sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,16 @@ sql admin
"type": "INT8"
},
{
"name": "?column?",
"name": "?column?_1",
"oid": 20,
"type": "INT8"
}
],
"end": "1970-01-01T00:00:00Z",
"rows": [
{
"?column?": 2
"?column?": 1,
"?column?_1": 2
}
],
"rows_affected": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func ingestionPlanHook(
destinationTenantID, err = sql.CreateTenantRecord(
ctx, p.ExecCfg().Codec, p.ExecCfg().Settings,
p.InternalSQLTxn(),
p.ExecCfg().SpanConfigKVAccessor.WithTxn(ctx, p.Txn()),
p.ExecCfg().SpanConfigKVAccessor.WithISQLTxn(ctx, p.InternalSQLTxn()),
tenantInfo, initialTenantZoneConfig,
ingestionStmt.IfNotExists,
p.ExecCfg().TenantTestingKnobs,
Expand Down
1 change: 1 addition & 0 deletions pkg/kv/kvclient/kvtenant/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ go_library(
"//pkg/server/settingswatcher",
"//pkg/settings",
"//pkg/spanconfig",
"//pkg/sql/isql",
"//pkg/sql/pgwire/pgcode",
"//pkg/sql/pgwire/pgerror",
"//pkg/ts/tspb",
Expand Down
6 changes: 6 additions & 0 deletions pkg/kv/kvclient/kvtenant/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/server/settingswatcher"
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/spanconfig"
"github.com/cockroachdb/cockroach/pkg/sql/isql"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/ts/tspb"
Expand Down Expand Up @@ -919,6 +920,11 @@ func (c *connector) WithTxn(context.Context, *kv.Txn) spanconfig.KVAccessor {
panic("not applicable")
}

// WithISQLTxn is part of the spanconfig.KVAccessor interface.
func (c *connector) WithISQLTxn(context.Context, isql.Txn) spanconfig.KVAccessor {
panic("not applicable")
}

// withClient is a convenience wrapper that executes the given closure while
// papering over InternalClient retrieval errors.
func (c *connector) withClient(
Expand Down

0 comments on commit 9434801

Please sign in to comment.