Skip to content

catalog: schema descriptor validation reads all functions under a schema #138384

@fqazi

Description

@fqazi

Presently, schema descriptor validation read all function descriptors under schema. This is problematic when concurrent CREATE TABLE statements referring to any function under a schema are executed will run into frequent transaction retry errors. The following scenario is a simple repro:

Setup:

CREATE FUNCTION public.example (input INT) RETURNS INT8
                                LANGUAGE SQL
                                AS $$
                                SELECT input::INT8;
                                $$;

CREATE FUNCTION public.wrap(input INT) RETURNS INT8
                                LANGUAGE SQL
                                AS $$
                                SELECT public.example(input);
                                $$;

CREATE FUNCTION public.wrap2(input INT) RETURNS INT8
                                LANGUAGE SQL
                                AS $$
                                SELECT public.example(input);
                                $$;

Conn 1:

BEGIN;
CREATE TABLE t3(i int8 default public.wrap2(10));

Conn 2:

BEGIN;
CREATE TABLE t2(i int8 default public.wrap(10));

One of the commits above will fail with a txn retry error, since the underlying descriptor used by validation is modified. Resolving the schema will validate all functions, leading to this bug.

Jira issue: CRDB-46065

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-supportWould prevent or help troubleshoot a customer escalation - bugs, missing observability/tooling, docsP-2Issues/test failures with a fix SLA of 3 monthsT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)branch-masterFailures and bugs on the master branch.branch-release-23.2Used to mark GA and release blockers, technical advisories, and bugs for 23.2branch-release-24.1Used to mark GA and release blockers, technical advisories, and bugs for 24.1branch-release-24.2Used to mark GA and release blockers, technical advisories, and bugs for 24.2branch-release-24.3Used to mark GA and release blockers, technical advisories, and bugs for 24.3v24.1.12v24.2.10v24.3.5

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions