puppetlabs / trapperkeeper

A services framework for Clojure / JVM applications.
https://tickets.puppetlabs.com/browse/TK
Apache License 2.0
587 stars 74 forks source link

Maximum number of services is limited to approximately 122 #294

Open frenchy64 opened 3 years ago

frenchy64 commented 3 years ago

Describe the Bug

Creating an app with around 122 services fails with a Method code too large! or other ASM error.

Expected Behavior

The app boots as normal.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create an app with 122 services or more (try 200 or 500 if struggling to reproduce).
  2. The following error is thrown at startup.
#error {
 :cause "Method code too large!"
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message "Syntax error compiling deftype* at (/private/var/folders/2k/l1qp7ynj66g5dm8hmwxj9gtm0000gn/T/form-init4085182321200531753.clj:1:1)."
   :data #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "/private/var/folders/2k/l1qp7ynj66g5dm8hmwxj9gtm0000gn/T/form-init4085182321200531753.clj", :symbol deftype*}
   :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 7119]}
  {:type java.lang.IndexOutOfBoundsException
   :message "Method code too large!"
   :at [clojure.asm.MethodWriter computeMethodInfoSize "MethodWriter.java" 2061]}]
 :trace
 [[clojure.asm.MethodWriter computeMethodInfoSize "MethodWriter.java" 2061]
  [clojure.asm.ClassWriter toByteArray "ClassWriter.java" 457]
  [clojure.lang.Compiler$ObjExpr compile "Compiler.java" 4672]
  [clojure.lang.Compiler$NewInstanceExpr build "Compiler.java" 8086]
  [clojure.lang.Compiler$NewInstanceExpr$DeftypeParser parse "Compiler.java" 7939]
  [clojure.lang.Compiler analyzeSeq "Compiler.java" 7111]
  [clojure.lang.Compiler analyze "Compiler.java" 6793]
  [clojure.lang.Compiler analyze "Compiler.java" 6749]
  [clojure.lang.Compiler$BodyExpr$Parser parse "Compiler.java" 6122]
  [clojure.lang.Compiler$LetExpr$Parser parse "Compiler.java" 6440]
  [clojure.lang.Compiler analyzeSeq "Compiler.java" 7111]
  [clojure.lang.Compiler analyze "Compiler.java" 6793]
  [clojure.lang.Compiler analyze "Compiler.java" 6749]
  [clojure.lang.Compiler$BodyExpr$Parser parse "Compiler.java" 6124]
  [clojure.lang.Compiler$FnMethod parse "Compiler.java" 5471]
  [clojure.lang.Compiler$FnExpr parse "Compiler.java" 4033]
  [clojure.lang.Compiler analyzeSeq "Compiler.java" 7109]
  [clojure.lang.Compiler analyze "Compiler.java" 6793]
  [clojure.lang.Compiler eval "Compiler.java" 7178]
  [clojure.lang.Compiler eval "Compiler.java" 7136]
  [clojure.core$eval invokeStatic "core.clj" 3202]
  [clojure.core$eval invoke "core.clj" 3198]
  [plumbing.graph.positional$def_graph_record invokeStatic "positional.clj" 19]
  [plumbing.graph.positional$def_graph_record invoke "positional.clj" 12]
  [plumbing.graph.positional$def_graph_record invokeStatic "positional.clj" 15]
  [plumbing.graph.positional$def_graph_record invoke "positional.clj" 12]
  [plumbing.graph.positional$graph_form invokeStatic "positional.clj" 60]
  [plumbing.graph.positional$graph_form invoke "positional.clj" 51]
  [plumbing.graph.positional$positional_flat_compile invokeStatic "positional.clj" 72]
  [plumbing.graph.positional$positional_flat_compile invoke "positional.clj" 68]
  [plumbing.graph$eager_compile invokeStatic "graph.clj" 140]
  [plumbing.graph$eager_compile invoke "graph.clj" 129]
  [puppetlabs.trapperkeeper.internal$compile_graph$fn__21868 invoke "internal.clj" 153]
  [puppetlabs.trapperkeeper.internal$compile_graph invokeStatic "internal.clj" 152]
  [puppetlabs.trapperkeeper.internal$compile_graph invoke "internal.clj" 136]
  [puppetlabs.trapperkeeper.internal$eval22567$build_app_STAR___22576$fn__22577 invoke "internal.clj" 588]
  [puppetlabs.trapperkeeper.internal$eval22567$build_app_STAR___22576 invoke "internal.clj" 561]
  [puppetlabs.trapperkeeper.core$build_app invokeStatic "core.clj" 46]
  [puppetlabs.trapperkeeper.core$build_app invoke "core.clj" 28]
  ... ;; SNIP corporate details
  [java.lang.Thread run "Thread.java" 829]]}

Environment

Additional Context

This is due to using eager-compile to compile service graphs, which fails for large graphs.

frenchy64 commented 2 years ago

This has been fixed upstream https://github.com/plumatic/plumbing/issues/138

Use [prismatic/plumbing 0.6.0] for the fix.