readysettech / readyset

Readyset is a MySQL and Postgres wire-compatible caching layer that sits in front of existing databases to speed up queries and horizontally scale read throughput. Under the hood, ReadySet caches the results of cached select statements and incrementally updates these results over time as the underlying data changes.
https://readyset.io
Other
4.54k stars 125 forks source link

Panic when replicating table with large numeric #1392

Open jscheid opened 1 month ago

jscheid commented 1 month ago

Describe the problem

Replicating large numeric values will cause Readyset to panic with the (counter-intuitive) error message Number less than minimum value that can be represented. (full backtrace)

To Reproduce

CREATE TABLE foo (a NUMERIC);
INSERT INTO foo (a) VALUES (154000200562066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000::NUMERIC);

Then arrange for the table to be replicated.

Expected behavior

Your documentation states:

Readyset does not support DECIMAL/NUMERIC values with a scale greater than 28, i.e., with more than 28 digits to the right of the decimal point. 'NaN', 'Infinity', and '-Infinity' are also not supported.

This value doesn't have any digits to the right of the decimal point, but maybe your documentation needs to be more precise and say "does not support values with more than 28 digits"?

Even then, the replication shouldn't panic. Perhaps it should do one of the following instead:

Ideally you would also provide guidance on how to ensure that the replicated table cannot contain unsupported values in the first place, such as a CHECK constraint. (I think even more ideal would be if Readyset refuses to replicate a table without that constraint, just as it refuses to replicate one with scale out of bounds.)

Environment