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

UDDSketch assertion at crates/udd-sketch/src/lib.rs:290:9 #396

Closed
tyhoff opened this issue Apr 20, 2022 · 7 comments · Fixed by #441
Closed

UDDSketch assertion at crates/udd-sketch/src/lib.rs:290:9 #396

tyhoff opened this issue Apr 20, 2022 · 7 comments · Fixed by #441
Labels
bug Something isn't working

Comments

@tyhoff
Copy link

tyhoff commented Apr 20, 2022

Relevant system information:

  • OS: Aiven's TimescaleDB provider
  • PostgreSQL version, 13.6
  • TimescaleDB Toolkit version: 1.5.1
  • Installation method: Aiven

Describe the bug
I hit an assert when I don't expect to when creating a UDDSketch.

To Reproduce
Apologies for the seemingly random test case, but here it goes.

CREATE TABLE "public"."timescale_bug" ("n" float8 NOT NULL);

Load the attached CSV file into the table.

Run

SELECT
	uddsketch(100, 0.01, CAST(n AS FLOAT))
FROM
	timescale_bug

Expected behavior
Obvious

Actual behavior

Query 1 ERROR: ERROR:  assertion failed: (self.gamma.powf(1.0 / f64::powi(2.0, self.compactions as i32)) -\n     other.gamma.powf(1.0 / f64::powi(2.0, other.compactions as i32))).abs() <\n    f64::EPSILON
CONTEXT:  crates/udd-sketch/src/lib.rs:290:9

Fudging with the bucket count or error will get it to work, but it's random when the assert is tripped.

timescale_bug.csv.zip

@tyhoff tyhoff added the bug Something isn't working label Apr 20, 2022
@rtwalker
Copy link
Contributor

Thanks for the report! Confirming I can reproduce (on about 1 out of every 10 queries) on 1.5.1 and also when building and installing the main branch.

Will let you know what I find!

@rtwalker
Copy link
Contributor

explain select uddsketch(100, 0.01, n::float)::text from timescale_bug;
                                           QUERY PLAN                                           
------------------------------------------------------------------------------------------------
 Finalize Aggregate  (cost=9233.67..9233.68 rows=1 width=32)
   ->  Gather  (cost=9233.44..9233.65 rows=2 width=32)
         Workers Planned: 2
         ->  Partial Aggregate  (cost=8233.44..8233.45 rows=1 width=32)
               ->  Parallel Seq Scan on timescale_bug  (cost=0.00..7343.15 rows=356115 width=8)

@bvanelli
Copy link

bvanelli commented Jun 3, 2022

What is the status on this one? Would an upgrade to > 1.60 solve this issue? I'm having the same bug.

@rtwalker
Copy link
Contributor

rtwalker commented Jun 3, 2022

We haven't included a fix for this bug yet. From what I can tell, it appears likely that at least one of the assertions we are making when combining the UDDSketches from different parallel workers is too sensitive to floating point arithmetic.

I will note that in testing this out, I haven't been able to trigger this bug after running
SET max_parallel_workers_per_gather = 0;

I'll be sure to update this issue once we've released a bug fix.

@tyhoff
Copy link
Author

tyhoff commented Jun 15, 2022

@rtwalker Thanks for digging into this one! Excited to try it out in the next release.

@jerryxwu
Copy link
Contributor

@tyhoff If you haven't noticed, we've just included the fix in the latest 1.8.0 release. We'd love to hear whether it's fixed for you or not.

@tyhoff
Copy link
Author

tyhoff commented Aug 2, 2022

@tyhoff If you haven't noticed, we've just included the fix in the latest 1.8.0 release. We'd love to hear whether it's fixed for you or not.

@jerryxwu I noticed! I'm still waiting for it to be published to Aiven (Timescale Managed) sadly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants