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

CompilationException on count(*) in co-related join since Trino 378 #24012

Open
takezoe opened this issue Nov 3, 2024 · 4 comments
Open

CompilationException on count(*) in co-related join since Trino 378 #24012

takezoe opened this issue Nov 3, 2024 · 4 comments

Comments

@takezoe
Copy link
Member

takezoe commented Nov 3, 2024

SQL:

-- Table c1000 has 1000 columns
-- Table c10 has 10 columns
SELECT * FROM c1000 t1 WHERE (SELECT COUNT(*) FROM c10 t2 WHERE t1.col0 = t2.col0) > 2;

Stacktrace:

com.google.common.util.concurrent.UncheckedExecutionException: io.airlift.bytecode.CompilationException: Error compiling class: io/trino/$gen/PagesHashStrategy_20241103_105832_49
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2085)
	at com.google.common.cache.LocalCache.get(LocalCache.java:4017)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4040)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4989)
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4996)
	at com.google.common.cache.ForwardingLoadingCache.getUnchecked(ForwardingLoadingCache.java:54)
	at io.trino.sql.gen.JoinCompiler.compilePagesHashStrategyFactory(JoinCompiler.java:170)
	at io.trino.operator.StreamingAggregationOperator$StreamingAggregation.<init>(StreamingAggregationOperator.java:198)
	at io.trino.operator.StreamingAggregationOperator.<init>(StreamingAggregationOperator.java:147)
	at io.trino.operator.StreamingAggregationOperator$Factory.create(StreamingAggregationOperator.java:120)
	at io.trino.operator.WorkProcessorOperatorAdapter.<init>(WorkProcessorOperatorAdapter.java:108)
	at io.trino.operator.WorkProcessorOperatorAdapter$Factory.createOperator(WorkProcessorOperatorAdapter.java:64)
	at io.trino.operator.DriverFactory.createDriver(DriverFactory.java:107)
	at io.trino.execution.SqlTaskExecution$DriverSplitRunnerFactory.createDriver(SqlTaskExecution.java:667)
	at io.trino.execution.SqlTaskExecution$DriverSplitRunner.processFor(SqlTaskExecution.java:879)
	at io.trino.execution.executor.dedicated.SplitProcessor.run(SplitProcessor.java:77)
	at io.trino.execution.executor.dedicated.TaskEntry$VersionEmbedderBridge.lambda$run$0(TaskEntry.java:201)
	at io.trino.$gen.Trino_dev____20241103_105232_2.run(Unknown Source)
	at io.trino.execution.executor.dedicated.TaskEntry$VersionEmbedderBridge.run(TaskEntry.java:202)
	at io.trino.execution.executor.scheduler.FairScheduler.runTask(FairScheduler.java:172)
	at io.trino.execution.executor.scheduler.FairScheduler.lambda$submit$0(FairScheduler.java:159)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1575)
Caused by: io.airlift.bytecode.CompilationException: Error compiling class: io/trino/$gen/PagesHashStrategy_20241103_105832_49
	at io.airlift.bytecode.ByteCodeGenerator.generateByteCode(ByteCodeGenerator.java:106)
	at io.airlift.bytecode.ClassGenerator.defineClasses(ClassGenerator.java:100)
	at io.airlift.bytecode.ClassGenerator.defineClass(ClassGenerator.java:90)
	at io.trino.util.CompilerUtils.defineClass(CompilerUtils.java:81)
	at io.trino.util.CompilerUtils.defineClass(CompilerUtils.java:75)
	at io.trino.sql.gen.JoinCompiler.internalCompileHashStrategy(JoinCompiler.java:260)
	at io.trino.sql.gen.JoinCompiler.lambda$new$1(JoinCompiler.java:121)
	at com.google.common.cache.CacheLoader$FunctionToCacheLoader.load(CacheLoader.java:169)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3574)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2316)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2189)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2079)
	... 27 more
Caused by: org.objectweb.asm.MethodTooLargeException: Method too large: io/trino/$gen/PagesHashStrategy_20241103_105832_49.rowEqualsRow (ILio/trino/spi/Page;ILio/trino/spi/Page;)Z
	at org.objectweb.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2088)
	at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:506)
	at io.airlift.bytecode.ByteCodeGenerator.generateByteCode(ByteCodeGenerator.java:103)
	... 38 more

The root cause of the compilation error is too many grouping keys came from c1000 on decorelated count(*).

Image

This query had worked until Trino 377 thanks to PushAggregationThroughOuterJoin which pushes aggregation below Left Join and reduced the number of grouping keys. However, PushFilterThroughCountAggregation was added in Trino 378 (#12047). It blocks PushAggregationThroughOuterJoin when applied.

I came up with some ideas to avoid this error but not sure if they are any good.

  • Shorten auto generated byte-code for rowEqualsRow (split to multiple methods?)
  • Skip PushFilterThroughCountAggregation if grouping keys are too many which has no chance to work
@wendigo
Copy link
Contributor

wendigo commented Nov 4, 2024

Have you tried newer Trino? Does it still occur?

@martint
Copy link
Member

martint commented Nov 4, 2024

Shorten auto generated byte-code for hashPosition (split to multiple methods?)

We should do this. Take a look at #23721 for a similar situation.

@takezoe
Copy link
Member Author

takezoe commented Nov 5, 2024

Have you tried newer Trino? Does it still occur?

Yes, this happens even on the latest master.

We should do this. Take a look at #23721 for a similar situation.

Thanks. Let me try.

@takezoe
Copy link
Member Author

takezoe commented Nov 6, 2024

The root cause of the compilation error is too many grouping keys came from c1000 on decorelated count(*).

Actually this happens in JoinCompiler due to too many joinChannels (as stacktrace says). The compilation error happens for many auto-generated methods which loops on joinChannelTypes.

If I remember correctly, it happened for hashPosition when we faced this error but Trino version was not the latest at that time. I will look into a bit more closely to see whether this difference is caused by the difference in Trino version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants