Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic when using watch schema cache with postgres #2250

Closed
vroldanbet opened this issue Feb 24, 2025 · 1 comment
Closed

panic when using watch schema cache with postgres #2250

vroldanbet opened this issue Feb 24, 2025 · 1 comment
Labels
kind/bug Something is broken or regressed

Comments

@vroldanbet
Copy link
Contributor

What platforms are affected?

macos

What architectures are affected?

arm64

What SpiceDB version are you using?

v1.40.0

Steps to Reproduce

A discord user reported a panic when using the watch schema cache.

From the stacktrace, what we can see is the postgres Watch API is returning a datastore.RevisionChanges that has a nil Revision, and causes it to panic when logging the revision change here and attempting to log the nil revision.

{"level":"info","revision":"CNT9lQM=","count":0,"time":"2025-02-18T13:34:11Z","message":"populated caveat watching cache"}
{"level":"debug","revision":"CNT9lQM=","watch-heartbeat":60000,"time":"2025-02-18T13:34:11Z","message":"beginning schema watch"}
{"level":"debug","time":"2025-02-18T13:34:11Z","message":"schema watch started"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x134ff0a]
goroutine 706 [running]:
github.com/authzed/spicedb/pkg/datastore.(*RevisionChanges).MarshalZerologObject(0x0, 0xc000b7a230)
    /home/runner/actions-runner/_work/spicedb/spicedb/pkg/datastore/datastore.go:72 +0x2a
github.com/rs/zerolog.(*Event).appendObject(0xc000b7a230, {0x3a759e0?, 0x0?})
    /home/runner/go/pkg/mod/github.com/rs/[email protected]/event.go:211 +0xa5
github.com/rs/zerolog.(*Event).Object(0xc000b7a230, {0x3473354?, 0x0?}, {0x3a759e0, 0x0})
    /home/runner/go/pkg/mod/github.com/rs/[email protected]/event.go:227 +0x18b
github.com/authzed/spicedb/internal/datastore/proxy/schemacaching.(*watchingCachingProxy).startSync.func2()
    /home/runner/actions-runner/_work/spicedb/spicedb/internal/datastore/proxy/schemacaching/watchingcache.go:264 +0xabd
created by github.com/authzed/spicedb/internal/datastore/proxy/schemacaching.(*watchingCachingProxy).startSync in goroutine 623
    /home/runner/actions-runner/_work/spicedb/spicedb/internal/datastore/proxy/schemacaching/watchingcache.go:185 +0x20f
Starting service..........Max attempts reached

Expected Result

No panic and no datastore.RevisionChange with a nil revision

Actual Result

server panics

@vroldanbet vroldanbet added the kind/bug Something is broken or regressed label Feb 24, 2025
@vroldanbet
Copy link
Contributor Author

I believe this was fixed in 1.40.1, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something is broken or regressed
Projects
None yet
Development

No branches or pull requests

1 participant