Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/cockroachdb/apd/v3 v3.2.3
github.com/cockroachdb/errors v1.7.5
github.com/dolthub/dolt/go v0.40.5-0.20260624213831-feba4a825720
github.com/dolthub/dolt/go v0.40.5-0.20260626214637-25552a68b104

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View All Evidence

High severity Persisted custom type deserialization crashes server on restart

What failed: The process crashes with SIGSEGV during root/table initialization because type deserialization requests a type collection with ctx=nil, and getContextValues dereferences ctx.Session without a nil guard.

Impact Β· Steps Β· Stub / mock Β· Analysis Β· Why this is likely a bug
  • Severity: High High severity
  • Impact: After creating and persisting ENUM-based schema, restarting the server can crash before it accepts connections, leaving affected databases unavailable until repaired. This blocks normal read/write access for users of those databases.
  • Steps to Reproduce:
    1. Start doltgres with a fresh data directory.
    2. Create an ENUM type and a table that uses that type, then insert rows.
    3. Stop the server and restart using the same data directory.
    4. Observe startup panic before ReadyForQuery with stack through recursiveDeserializeType -> GetTypesCollectionFromContext -> getContextValues.
  • Stub / mock content: No stubs, mocks, or bypasses were applied for this test in the recorded run.
  • Code Analysis: core/context.go assumes ctx is non-nil in getContextValues (line 56), and core/context.go line 421 calls that helper from GetTypesCollectionFromContext without validating ctx. During startup deserialization, server/types/serialization.go line 267 calls GetTypesCollectionFromContext(ctx, "") when ctx may be nil in this dependency path. The PR diff modified go.mod dependency lines (9, 12, 15) and the panic stack shows the new go-mysql-server and dolt versions on this call chain, making this a regression introduced by changed dependency code paths. Smallest practical fix: add explicit nil-context handling in GetTypesCollectionFromContext/getContextValues and/or avoid calling context-dependent type collection lookup from recursiveDeserializeType when ctx is nil during startup deserialization.
  • Why this is likely a bug: This is a production-code startup path and the observed panic is a deterministic nil-pointer dereference in repository code, not a harness artifact. A database containing valid persisted custom-type metadata should not make the server crash before it can accept connections.
Relevant code

go.mod:9-12

github.com/dolthub/dolt/go v0.40.5-0.20260626214637-25552a68b104
github.com/dolthub/go-mysql-server v0.20.1-0.20260626203645-7c333f13eaca

core/context.go:55-57

func getContextValues(ctx *sql.Context) (*contextValues, error) {
	sess := dsess.DSessFromSess(ctx.Session)
	if sess.DoltgresSessObj == nil {

core/context.go:420-422

func GetTypesCollectionFromContext(ctx *sql.Context, database string) (*typecollection.TypeCollection, error) {
	cv, err := getContextValues(ctx)
	if err != nil {

server/types/serialization.go:266-268

if typeColl == nil {
	typeColl, err = GetTypesCollectionFromContext(ctx, "")
	if err != nil {
Evidence Package
Copy prompt for an agent
Ito QA identified the following failure during automated PR testing. Please investigate and propose a fix.

**High severity β€” Persisted custom type deserialization crashes server on restart**

**What failed:** The process crashes with SIGSEGV during root/table initialization because type deserialization requests a type collection with ctx=nil, and getContextValues dereferences ctx.Session without a nil guard.

- **Impact:** After creating and persisting ENUM-based schema, restarting the server can crash before it accepts connections, leaving affected databases unavailable until repaired. This blocks normal read/write access for users of those databases.
- **Steps to reproduce:**
  1. Start doltgres with a fresh data directory.
  2. Create an ENUM type and a table that uses that type, then insert rows.
  3. Stop the server and restart using the same data directory.
  4. Observe startup panic before ReadyForQuery with stack through recursiveDeserializeType -> GetTypesCollectionFromContext -> getContextValues.
- **Stub / mock content:** No stubs, mocks, or bypasses were applied for this test in the recorded run.
- **Code analysis:** core/context.go assumes ctx is non-nil in getContextValues (line 56), and core/context.go line 421 calls that helper from GetTypesCollectionFromContext without validating ctx. During startup deserialization, server/types/serialization.go line 267 calls GetTypesCollectionFromContext(ctx, "") when ctx may be nil in this dependency path. The PR diff modified go.mod dependency lines (9, 12, 15) and the panic stack shows the new go-mysql-server and dolt versions on this call chain, making this a regression introduced by changed dependency code paths. Smallest practical fix: add explicit nil-context handling in GetTypesCollectionFromContext/getContextValues and/or avoid calling context-dependent type collection lookup from recursiveDeserializeType when ctx is nil during startup deserialization.
- **Why this is likely a bug:** This is a production-code startup path and the observed panic is a deterministic nil-pointer dereference in repository code, not a harness artifact. A database containing valid persisted custom-type metadata should not make the server crash before it can accept connections.

**Relevant code:**

`go.mod:9-12`

~~~go
github.com/dolthub/dolt/go v0.40.5-0.20260626214637-25552a68b104
github.com/dolthub/go-mysql-server v0.20.1-0.20260626203645-7c333f13eaca
~~~

`core/context.go:55-57`

~~~go
func getContextValues(ctx *sql.Context) (*contextValues, error) {
	sess := dsess.DSessFromSess(ctx.Session)
	if sess.DoltgresSessObj == nil {
~~~

`core/context.go:420-422`

~~~go
func GetTypesCollectionFromContext(ctx *sql.Context, database string) (*typecollection.TypeCollection, error) {
	cv, err := getContextValues(ctx)
	if err != nil {
~~~

`server/types/serialization.go:266-268`

~~~go
if typeColl == nil {
	typeColl, err = GetTypesCollectionFromContext(ctx, "")
	if err != nil {
~~~

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View All Evidence

High severity Persisted schema loads while referenced custom type fails resolution

What failed: During restart, type deserialization for persisted table schemas executes with a nil *sql.Context and dereferences ctx.Session in core.getContextValues, causing a SIGSEGV and process exit.

Impact Β· Steps Β· Stub / mock Β· Analysis Β· Why this is likely a bug
  • Severity: High High severity
  • Impact: Servers that restart with persisted tables using custom ENUM or COMPOSITE types can crash on startup, making affected databases unavailable. Users cannot reliably bring the service back up for those datasets until the defect is fixed or the data is changed.
  • Steps to Reproduce:
    1. Start doltgres with a fresh DOLTGRES_DATA_DIR and create custom types plus tables that use those types.
    2. Insert rows, stop the server, then restart using the same data directory.
    3. Observe startup panic: stack reaches recursiveDeserializeType -> GetTypesCollectionFromContext(nil) -> getContextValues and crashes before ReadyForQuery.
  • Stub / mock content: No stubs, mocks, or bypasses were applied for this test in the recorded run.
  • Code Analysis: The panic is code-backed in repository paths: core/context.go dereferences ctx.Session without a nil guard, and core/init.go registers GetTypesCollectionFromContext for type resolution used by server/types/serialization.go recursiveDeserializeType. Runtime evidence shows this path is exercised from dependency code during startup table iteration. PR context shows only dependency updates in go.mod/go.sum, with go.mod changed lines bumping github.com/dolthub/dolt/go and github.com/dolthub/go-mysql-server; the stack trace references those bumped module versions and the regression appears when those changed dependency lines are in place.
  • Why this is likely a bug: A persisted data directory that previously operated should not make the server crash during restart. The production startup path dereferences a nil context and aborts the process instead of handling unresolved custom-type loading deterministically.
Relevant code

go.mod:9-12

github.com/dolthub/dolt/go v0.40.5-0.20260626214637-25552a68b104
github.com/dolthub/go-mysql-server v0.20.1-0.20260626203645-7c333f13eaca

core/context.go:55-57

func getContextValues(ctx *sql.Context) (*contextValues, error) {
	sess := dsess.DSessFromSess(ctx.Session)
	if sess.DoltgresSessObj == nil {

server/types/serialization.go:266-268

if typeColl == nil {
	typeColl, err = GetTypesCollectionFromContext(ctx, "")
	if err != nil {

core/init.go:40-42

pgtypes.GetTypesCollectionFromContext = func(ctx *sql.Context, database string) (pgtypes.TypeCollection, error) {
	return GetTypesCollectionFromContext(ctx, database)
}
Evidence Package
Copy prompt for an agent
Ito QA identified the following failure during automated PR testing. Please investigate and propose a fix.

**High severity β€” Persisted schema loads while referenced custom type fails resolution**

**What failed:** During restart, type deserialization for persisted table schemas executes with a nil *sql.Context and dereferences ctx.Session in core.getContextValues, causing a SIGSEGV and process exit.

- **Impact:** Servers that restart with persisted tables using custom ENUM or COMPOSITE types can crash on startup, making affected databases unavailable. Users cannot reliably bring the service back up for those datasets until the defect is fixed or the data is changed.
- **Steps to reproduce:**
  1. Start doltgres with a fresh DOLTGRES_DATA_DIR and create custom types plus tables that use those types.
  2. Insert rows, stop the server, then restart using the same data directory.
  3. Observe startup panic: stack reaches recursiveDeserializeType -> GetTypesCollectionFromContext(nil) -> getContextValues and crashes before ReadyForQuery.
- **Stub / mock content:** No stubs, mocks, or bypasses were applied for this test in the recorded run.
- **Code analysis:** The panic is code-backed in repository paths: core/context.go dereferences ctx.Session without a nil guard, and core/init.go registers GetTypesCollectionFromContext for type resolution used by server/types/serialization.go recursiveDeserializeType. Runtime evidence shows this path is exercised from dependency code during startup table iteration. PR context shows only dependency updates in go.mod/go.sum, with go.mod changed lines bumping github.com/dolthub/dolt/go and github.com/dolthub/go-mysql-server; the stack trace references those bumped module versions and the regression appears when those changed dependency lines are in place.
- **Why this is likely a bug:** A persisted data directory that previously operated should not make the server crash during restart. The production startup path dereferences a nil context and aborts the process instead of handling unresolved custom-type loading deterministically.

**Relevant code:**

`go.mod:9-12`

~~~gomod
github.com/dolthub/dolt/go v0.40.5-0.20260626214637-25552a68b104
github.com/dolthub/go-mysql-server v0.20.1-0.20260626203645-7c333f13eaca
~~~

`core/context.go:55-57`

~~~go
func getContextValues(ctx *sql.Context) (*contextValues, error) {
	sess := dsess.DSessFromSess(ctx.Session)
	if sess.DoltgresSessObj == nil {
~~~

`server/types/serialization.go:266-268`

~~~go
if typeColl == nil {
	typeColl, err = GetTypesCollectionFromContext(ctx, "")
	if err != nil {
~~~

`core/init.go:40-42`

~~~go
pgtypes.GetTypesCollectionFromContext = func(ctx *sql.Context, database string) (pgtypes.TypeCollection, error) {
	return GetTypesCollectionFromContext(ctx, database)
}
~~~

github.com/dolthub/eventsapi_schema v0.0.0-20260310172945-37a9265ade69
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.20.1-0.20260623224402-eee792a22ff6
github.com/dolthub/go-mysql-server v0.20.1-0.20260626203645-7c333f13eaca
github.com/dolthub/pg_query_go/v6 v6.0.0-20251215122834-fb20be4254d1
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216
github.com/dolthub/vitess v0.0.0-20260617012411-2f308f6cdc23
github.com/dolthub/vitess v0.0.0-20260624214226-81d034e0fde8
github.com/fatih/color v1.13.0
github.com/goccy/go-json v0.10.2
github.com/gogo/protobuf v1.3.2
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12 h1:I
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12/go.mod h1:rN7X8BHwkjPcfMQQ2QTAq/xM3leUSGLfb+1Js7Y6TVo=
github.com/dolthub/dolt-mcp v0.3.4 h1:AyG5cw+fNWXDHXujtQnqUPZrpWtPg6FN6yYtjv1pP44=
github.com/dolthub/dolt-mcp v0.3.4/go.mod h1:bCZ7KHvDYs+M0e+ySgmGiNvLhcwsN7bbf5YCyillLrk=
github.com/dolthub/dolt/go v0.40.5-0.20260624213831-feba4a825720 h1:SHrZF+kl97eA7xUUelGC0QKXpxmfMlU3uMR7ATDTe9w=
github.com/dolthub/dolt/go v0.40.5-0.20260624213831-feba4a825720/go.mod h1:Ag5UOmZsjACE4bx1AmahSCf0HiOO4avxvyOQebVGKXM=
github.com/dolthub/dolt/go v0.40.5-0.20260626214637-25552a68b104 h1:TiOLklwJs2iYwdLziugSIegjDkaLknQu8sMKOoC21Wk=
github.com/dolthub/dolt/go v0.40.5-0.20260626214637-25552a68b104/go.mod h1:hXtlbek0gmWqRBlDVc/RAv7h7hKo8jFiiz92Wz3rIH4=
github.com/dolthub/eventsapi_schema v0.0.0-20260310172945-37a9265ade69 h1:JShhbqMw26nKx3pqqu/cFxOpzBkN+4elVhzuUfgDw2k=
github.com/dolthub/eventsapi_schema v0.0.0-20260310172945-37a9265ade69/go.mod h1:SSLraQS/jGLYFgff3vuZ+JbVUct6vyEeMzjLBqWqoyM=
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww=
Expand All @@ -256,8 +256,8 @@ github.com/dolthub/fslock v0.0.5 h1:QoXhBhgY1oumHE26qyE7tgmXUT8qjJwxsIzo54O/B/k=
github.com/dolthub/fslock v0.0.5/go.mod h1:sdofYYqE0D79zNZyB4/kmlnsQOVap1C2yByjGKSirEM=
github.com/dolthub/go-icu-regex v0.0.0-20260610153742-72563bc7ca83 h1:FEMjCGEroDnY/BXyAffVZxUpXhP2GpoUJyyq5KaLn8c=
github.com/dolthub/go-icu-regex v0.0.0-20260610153742-72563bc7ca83/go.mod h1:F3cnm+vMRK1HaU6+rNqQrOCyR03HHhR1GWG2gnPOqaE=
github.com/dolthub/go-mysql-server v0.20.1-0.20260623224402-eee792a22ff6 h1:vtPT9yQVaZoJ17llG4U1RDMIUYlgiJio/WJ7zWTXNbE=
github.com/dolthub/go-mysql-server v0.20.1-0.20260623224402-eee792a22ff6/go.mod h1:nd4+RZ0rp2P4JnJ16UwJPEBPN7kfYiaYQscnGyh1NYA=
github.com/dolthub/go-mysql-server v0.20.1-0.20260626203645-7c333f13eaca h1:RfJumNpQS/oTwPGlq6AYDR5dHGB9W2U63uXeFDRwOMw=
github.com/dolthub/go-mysql-server v0.20.1-0.20260626203645-7c333f13eaca/go.mod h1:mj5/QX3V8i92REbA1w6CzyknJAFdKtdE7l931405C/E=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
github.com/dolthub/ishell v0.0.0-20260414231531-5f031e3e9037 h1:oIW9HwuWrhxv+4HZxA+QQSKHLqWFyXZ2FmNjUYwkdiM=
Expand All @@ -268,8 +268,8 @@ github.com/dolthub/pg_query_go/v6 v6.0.0-20251215122834-fb20be4254d1 h1:GY17cGA4
github.com/dolthub/pg_query_go/v6 v6.0.0-20251215122834-fb20be4254d1/go.mod h1:qnrZP3/1slFl2Bq5yw38HLOsArZareGwdpEceriblLc=
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216 h1:JWkKRE4EHUcEVQCMRBej8DYxjYjRz/9MdF/NNQh0o70=
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216/go.mod h1:e/FIZVvT2IR53HBCAo41NjqgtEnjMJGKca3Y/dAmZaA=
github.com/dolthub/vitess v0.0.0-20260617012411-2f308f6cdc23 h1:1yEYWCBuhxDdbUGorvhA3JPnUIFHZr2qXuJ4AKBHLC0=
github.com/dolthub/vitess v0.0.0-20260617012411-2f308f6cdc23/go.mod h1:5SVEJgAhw5nnQUFnGgKI1Svqes1Mw+zKUsalyxmOuG0=
github.com/dolthub/vitess v0.0.0-20260624214226-81d034e0fde8 h1:zmKLyRCTiNZnizO++sNXP1QW2bxLE2Y+WJAdu/hcu6s=
github.com/dolthub/vitess v0.0.0-20260624214226-81d034e0fde8/go.mod h1:5SVEJgAhw5nnQUFnGgKI1Svqes1Mw+zKUsalyxmOuG0=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
Expand Down
Loading