Repository navigation
v4.4.1
Nuthatch 4.4.1 fixes wrong answers. From 4.2.1 through 4.4.0, an integer division over a HUGEINT that
had passed through COALESCE or IFNULL was computed in floating point, so delegator positions and
fee splits came back wrong. Upgrade any nest that runs those releases.
What was wrong
On the allocations nest, six of the release gate's 74 production statements answered wrong:
indexer.delegators_page, indexer.daily, indexer.revenue_daily, indexer.revenue_by_deployment,
delegator.stakes and delegator.active_stakes. A delegator's current tokens read about twice what
they are (417562027912000000000000 against 208781013956236784173056 for one delegator), net fees lost
their low digits (35791310786500000000000 against 35791310786466491123153), and a zero came back as
0.0. 4.0.2 to 4.2.0 answered these exactly.
Cause
COALESCE(x, 0) over a HUGEINT widens the integer literal with a cast to DECIMAL(38,0), as DuckDB
does. Burrmill's rule for // treats a written DECIMAL(38,0) as decimal and divides it in DOUBLE,
and it read that inserted cast as a written one, so share_amount // COALESCE(delegator_shares, 0)
and x * (1000000 - COALESCE(cut, 0)) // 1000000 stopped being integer division. The same widening
applies to CASE, greatest, least and NULLIF. The inserted casts now carry the HUGEINT mark a
written CAST(x AS HUGEINT) has, and // stays exact. A real DECIMAL argument still divides in
DOUBLE, as in DuckDB.
IFNULL was worse: it mapped to DataFusion's nvl, which has no DECIMAL signature, so
IFNULL(x, 0) returned DOUBLE on its own, for a HUGEINT, a DECIMAL or a UBIGINT alike. It is now
COALESCE, and is named COALESCE(...) as DuckDB names it. (nuthatch-org/burrmill#69)
How it was found
Not by the release gate's comparison with the previous release, which every release since 4.2.1
passed, because each made the same mistake. The DuckDB reference (#1796) runs the same statements
through DuckDB over the nest copy at its sealed pin, and these six were the only ones that differed.
Measured
On Linux, against a copy of the allocations nest, under production's budget:
- DuckDB reference, pinned at sealed_through 511553826: 74 statements, 72 match DuckDB, the 2 volatile
ones equal on row count, 0 differ. 4.4.0 on the same pin: 6 differ. - Release gate against 4.4.0, two statements at a time, three passes: 74 of 74 answered, none
regressed, exactly the six statements above differ. Peak RSS 1,767 MiB against 4.4.0's 1,743 MiB,
inside the 2,048 MiB budget; p99 2,322 ms against 2,327 ms.
Compatibility and upgrade
Replace the binary and restart. There is no storage migration or re-index.