Uploaded image for project: 'PuppetDB'
  1. PuppetDB
  2. PDB-4347

Don't use a static temp table name for fact path gc

    Details

    • Template:
    • Team:
      PuppetDB
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      PuppetDB should no longer log errors like this if a previous garbage collection had failed in a particular way: "Error during garbage collection" "ERROR: relation "tmp_live_paths" already exists".
    • QA Risk Assessment:
      Needs Assessment

      Description

      Using a static table for fact path gc is causing the following error to occur if multiple GC's occur at the same time or it a server crashes during GC.

      2019-04-22T11:45:14.721-07:00 ERROR [p.p.c.services] Error during garbage collection
      2019-04-22T11:45:14.721-07:00 ERROR [p.p.c.services] Error during garbage collection
      java.sql.BatchUpdateException: Batch entry 0 
      WITH recursive live_paths(path, value) AS
      (
             SELECT KEY AS path,
                    value
             FROM   (
                           SELECT (jsonb_each(stable
                                         ||volatile)).*
                           FROM   factsets) AS base_case
             UNION
             SELECT path
                           ||'#~'
                           ||sub_level.KEY AS path,
                    sub_level.value
             FROM   live_paths,
                    lateral
                    (
                           SELECT *
                           FROM   (
                                         SELECT (jsonb_each(value)).*
                                         WHERE  jsonb_typeof(value) = 'object') AS sub_fields
                           UNION
                                 (
                                        SELECT generate_series(0, jsonb_array_length(value - 1))::text AS KEY,
                                               jsonb_array_elements(value)                             AS value
                                        WHERE  jsonb_typeof(value) = 'array')) AS sub_level)
      SELECT path
      INTO   unlogged tmp_live_paths
      FROM   live_paths 
       
      was aborted: ERROR: relation "tmp_live_paths" already exists
      Call getNextException to see other errors in the batch.
      at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:148)
      at org.postgresql.core.ResultHandlerDelegate.handleError(ResultHandlerDelegate.java:50)
      at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2179)
      at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:479)
      at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:835)
      at com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:128)
      at com.zaxxer.hikari.pool.HikariProxyStatement.executeBatch(HikariProxyStatement.java)
      at clojure.java.jdbc$execute_batch.invokeStatic(jdbc.clj:563)
      at clojure.java.jdbc$execute_batch.invoke(jdbc.clj:556)
      at clojure.java.jdbc$db_do_commands$fn__21279.invoke(jdbc.clj:906)
      at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:814)
      at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:741)
      at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:754)
      at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:741)
      at clojure.java.jdbc$db_do_commands.invokeStatic(jdbc.clj:905)
      at clojure.java.jdbc$db_do_commands.invoke(jdbc.clj:890)
      at puppetlabs.puppetdb.jdbc$do_commands.invokeStatic(jdbc.clj:38)
      at puppetlabs.puppetdb.jdbc$do_commands.doInvoke(jdbc.clj:33)
      at clojure.lang.RestFn.invoke(RestFn.java:457)
      at puppetlabs.puppetdb.scf.storage$delete_unused_fact_paths.invokeStatic(storage.clj:1151)
      at puppetlabs.puppetdb.scf.storage$delete_unused_fact_paths.invoke(storage.clj:1140)
      at puppetlabs.puppetdb.scf.storage$garbage_collect_BANG_$fn__27899$fn__27902.invoke(storage.clj:1468)
      at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn$fn__21879$fn__21880.invoke(jdbc.clj:483)
      at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:771)
      at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:741)
      at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn$fn__21879.invoke(jdbc.clj:482)
      at puppetlabs.puppetdb.jdbc$fn__21857$retry_sql_STAR___21862$fn__21863$fn__21864.invoke(jdbc.clj:454)
      at puppetlabs.puppetdb.jdbc$fn__21857$retry_sql_STAR___21862$fn__21863.invoke(jdbc.clj:453)
      at puppetlabs.puppetdb.jdbc$fn__21857$retry_sql_STAR___21862.invoke(jdbc.clj:444)
      at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn.invokeStatic(jdbc.clj:480)
      at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn.invoke(jdbc.clj:469)
      at puppetlabs.puppetdb.scf.storage$garbage_collect_BANG_$fn__27899.invoke(storage.clj:1465)
      at puppetlabs.puppetdb.scf.storage.proxy$java.lang.Object$Callable$7da976d4.call(Unknown Source)
      at com.codahale.metrics.Timer.time(Timer.java:101)
      at puppetlabs.puppetdb.scf.storage$garbage_collect_BANG_.invokeStatic(storage.clj:1459)
      at puppetlabs.puppetdb.scf.storage$garbage_collect_BANG_.invoke(storage.clj:1456)
      at puppetlabs.puppetdb.cli.services$garbage_collect_BANG_.invokeStatic(services.clj:193)
      at puppetlabs.puppetdb.cli.services$garbage_collect_BANG_.invoke(services.clj:184)
      at puppetlabs.puppetdb.cli.services$fn__34894$clean_up__34899$fn__34903$fn__34913.invoke(services.clj:263)
      at puppetlabs.puppetdb.cli.services.proxy$java.lang.Object$Callable$7da976d4.call(Unknown Source)
      at com.codahale.metrics.Timer.time(Timer.java:101)
      at puppetlabs.puppetdb.cli.services$fn__34894$clean_up__34899$fn__34903.invoke(services.clj:262)
      at puppetlabs.puppetdb.cli.services$fn__34894$clean_up__34899.invoke(services.clj:224)
      at puppetlabs.puppetdb.cli.services$collect_garbage.invokeStatic(services.clj:384)
      at puppetlabs.puppetdb.cli.services$collect_garbage.invoke(services.clj:379)
      at puppetlabs.puppetdb.cli.services$coordinate_gc_with_shutdown.invokeStatic(services.clj:400)
      at puppetlabs.puppetdb.cli.services$coordinate_gc_with_shutdown.invoke(services.clj:390)
      at puppetlabs.puppetdb.cli.services$start_puppetdb$fn__34986.invoke(services.clj:477)
      at clojure.lang.AFn.run(AFn.java:22)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)Caused by: org.postgresql.util.PSQLException: ERROR: relation "tmp_live_paths" already exists
      at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
      at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178)
      
      

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  rob.browning Rob Browning
                  Reporter:
                  austin.blatt Austin Blatt
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: