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

PG 10.0 - PG::UndefinedFunction - pg_xlog_location_diff & pg_current_xlog_insert_location #16052

Closed
himdel opened this issue Sep 26, 2017 · 9 comments
Assignees
Labels

Comments

@himdel
Copy link
Contributor

himdel commented Sep 26, 2017

Starting with postgres 10.0, xlog was renamed to wal and all related functions got renamed as well. Also, looks like location got changed to lsn (ref).

This causes 3 more (in addition to #13200) failures...

  1) PglogicalSubscription#backlog returns the correct value
     Failure/Error: select_value("SELECT pg_xlog_location_diff(#{quote(lsn1)}, #{quote(lsn2)})").to_i
     
     ActiveRecord::StatementInvalid:
       PG::UndefinedFunction: ERROR:  function pg_xlog_location_diff(unknown, unknown) does not exist
       LINE 1: SELECT pg_xlog_location_diff('0/42108F8', '0/420D9A0')
                      ^
       HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
       : SELECT pg_xlog_location_diff('0/42108F8', '0/420D9A0')
     # ./lib/extensions/ar_adapter/ar_dba.rb:19:in `xlog_location_diff'
     # ./app/models/pglogical_subscription.rb:105:in `backlog'
     # ./spec/models/pglogical_subscription_spec.rb:422:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # PG::UndefinedFunction:
     #   ERROR:  function pg_xlog_location_diff(unknown, unknown) does not exist
     #   LINE 1: SELECT pg_xlog_location_diff('0/42108F8', '0/420D9A0')
     #                  ^
     #   HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
     #   ./lib/extensions/ar_adapter/ar_dba.rb:19:in `xlog_location_diff'

  2) ar_dba extension #xlog_location returns a valid lsn
     Failure/Error: select_value("SELECT pg_current_xlog_insert_location()")
     
     ActiveRecord::StatementInvalid:
       PG::UndefinedFunction: ERROR:  function pg_current_xlog_insert_location() does not exist
       LINE 1: SELECT pg_current_xlog_insert_location()
                      ^
       HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
       : SELECT pg_current_xlog_insert_location()
     # ./lib/extensions/ar_adapter/ar_dba.rb:15:in `xlog_location'
     # ./spec/lib/extensions/ar_dba_spec.rb:6:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # PG::UndefinedFunction:
     #   ERROR:  function pg_current_xlog_insert_location() does not exist
     #   LINE 1: SELECT pg_current_xlog_insert_location()
     #                  ^
     #   HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
     #   ./lib/extensions/ar_adapter/ar_dba.rb:15:in `xlog_location'

  3) ar_dba extension #xlog_location_diff returns the correct xlog difference
     Failure/Error: select_value("SELECT pg_xlog_location_diff(#{quote(lsn1)}, #{quote(lsn2)})").to_i
     
     ActiveRecord::StatementInvalid:
       PG::UndefinedFunction: ERROR:  function pg_xlog_location_diff(unknown, unknown) does not exist
       LINE 1: SELECT pg_xlog_location_diff('18/72F84A48', '18/72F615B8')
                      ^
       HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
       : SELECT pg_xlog_location_diff('18/72F84A48', '18/72F615B8')
     # ./lib/extensions/ar_adapter/ar_dba.rb:19:in `xlog_location_diff'
     # ./spec/lib/extensions/ar_dba_spec.rb:12:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # PG::UndefinedFunction:
     #   ERROR:  function pg_xlog_location_diff(unknown, unknown) does not exist
     #   LINE 1: SELECT pg_xlog_location_diff('18/72F84A48', '18/72F615B8')
     #                  ^
     #   HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
     #   ./lib/extensions/ar_adapter/ar_dba.rb:19:in `xlog_location_diff'

Finished in 12 minutes 19 seconds (files took 34.74 seconds to load)
1922 examples, 3 failures, 1 pending

Failed examples:

rspec ./spec/models/pglogical_subscription_spec.rb:418 # PglogicalSubscription#backlog returns the correct value
rspec ./spec/lib/extensions/ar_dba_spec.rb:5 # ar_dba extension #xlog_location returns a valid lsn
rspec ./spec/lib/extensions/ar_dba_spec.rb:11 # ar_dba extension #xlog_location_diff returns the correct xlog difference

Looks like just a rename..

  • pg_xlog_location_diff -> pg_wal_lsn_diff
  • pg_current_xlog_insert_location -> pg_current_wal_insert_lsn
diff --git a/lib/extensions/ar_adapter/ar_dba.rb b/lib/extensions/ar_adapter/ar_dba.rb
index c1db88cd77..42729b4d9d 100644
--- a/lib/extensions/ar_adapter/ar_dba.rb
+++ b/lib/extensions/ar_adapter/ar_dba.rb
@@ -12,11 +12,11 @@ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
   end
 
   def xlog_location
-    select_value("SELECT pg_current_xlog_insert_location()")
+    select_value("SELECT pg_current_wal_insert_lsn()")
   end
 
   def xlog_location_diff(lsn1, lsn2)
-    select_value("SELECT pg_xlog_location_diff(#{quote(lsn1)}, #{quote(lsn2)})").to_i
+    select_value("SELECT pg_wal_lsn_diff(#{quote(lsn1)}, #{quote(lsn2)})").to_i
   end
 
   def client_connections

seems to fix it, but there's also pglogical/client.rb, and I guess compatibility concerns..

But as with 9.6, most of the UI is unaffected.

@himdel
Copy link
Contributor Author

himdel commented Sep 26, 2017

@miq-bot add_label bug, postgresql10.0

(except it doesn't exist)

@miq-bot
Copy link
Member

miq-bot commented Sep 26, 2017

@himdel Cannot apply the following label because they are not recognized: postgres10.0

@miq-bot
Copy link
Member

miq-bot commented Apr 2, 2018

This issue has been automatically marked as stale because it has not been updated for at least 6 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions!

@miq-bot miq-bot added the stale label Apr 2, 2018
@himdel
Copy link
Contributor Author

himdel commented Apr 3, 2018

keepalive... @miq-bot remove_label stale

@miq-bot
Copy link
Member

miq-bot commented Apr 3, 2018

@himdel Cannot apply the following label because they are not recognized: postgresql10.0

@JPrause
Copy link
Member

JPrause commented Jan 23, 2019

@himdel is this still a valid issue. If not can you close.
If there's no update by next week, I'll be closing this issue.

@himdel
Copy link
Contributor Author

himdel commented Jan 23, 2019

Confirmed, this is still true (for postgresql 10+):

$ apt policy postgresql
postgresql:
  Installed: 11+198
...

$ bundle exec rspec spec/models/pglogical_subscription_spec.rb spec/lib/extensions/ar_dba_spec.rb
...
Failures:

  1) ar_dba extension #xlog_location_diff returns the correct xlog difference
     Failure/Error: select_value("SELECT pg_xlog_location_diff(#{quote(lsn1)}, #{quote(lsn2)})").to_i
     
     ActiveRecord::StatementInvalid:
       PG::UndefinedFunction: ERROR:  function pg_xlog_location_diff(unknown, unknown) does not exist
       LINE 1: SELECT pg_xlog_location_diff('18/72F84A48', '18/72F615B8')
                      ^
       HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
       : SELECT pg_xlog_location_diff('18/72F84A48', '18/72F615B8')
     # ./lib/extensions/ar_adapter/ar_dba.rb:19:in `xlog_location_diff'
     # ./spec/lib/extensions/ar_dba_spec.rb:12:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # PG::UndefinedFunction:
     #   ERROR:  function pg_xlog_location_diff(unknown, unknown) does not exist
     #   LINE 1: SELECT pg_xlog_location_diff('18/72F84A48', '18/72F615B8')
     #                  ^
     #   HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
     #   ./lib/extensions/ar_adapter/ar_dba.rb:19:in `xlog_location_diff'

  2) ar_dba extension #xlog_location returns a valid lsn
     Failure/Error: select_value("SELECT pg_current_xlog_insert_location()")
     
     ActiveRecord::StatementInvalid:
       PG::UndefinedFunction: ERROR:  function pg_current_xlog_insert_location() does not exist
       LINE 1: SELECT pg_current_xlog_insert_location()
                      ^
       HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
       : SELECT pg_current_xlog_insert_location()
     # ./lib/extensions/ar_adapter/ar_dba.rb:15:in `xlog_location'
     # ./spec/lib/extensions/ar_dba_spec.rb:6:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # PG::UndefinedFunction:
     #   ERROR:  function pg_current_xlog_insert_location() does not exist
     #   LINE 1: SELECT pg_current_xlog_insert_location()
     #                  ^
     #   HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
     #   ./lib/extensions/ar_adapter/ar_dba.rb:15:in `xlog_location'

  3) PglogicalSubscription#backlog returns the correct value
     Failure/Error: select_value("SELECT pg_xlog_location_diff(#{quote(lsn1)}, #{quote(lsn2)})").to_i
     
     ActiveRecord::StatementInvalid:
       PG::UndefinedFunction: ERROR:  function pg_xlog_location_diff(unknown, unknown) does not exist
       LINE 1: SELECT pg_xlog_location_diff('0/42108F8', '0/420D9A0')
                      ^
       HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
       : SELECT pg_xlog_location_diff('0/42108F8', '0/420D9A0')
     # ./lib/extensions/ar_adapter/ar_dba.rb:19:in `xlog_location_diff'
     # ./app/models/pglogical_subscription.rb:111:in `backlog'
     # ./spec/models/pglogical_subscription_spec.rb:479:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # PG::UndefinedFunction:
     #   ERROR:  function pg_xlog_location_diff(unknown, unknown) does not exist
     #   LINE 1: SELECT pg_xlog_location_diff('0/42108F8', '0/420D9A0')
     #                  ^
     #   HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
     #   ./lib/extensions/ar_adapter/ar_dba.rb:19:in `xlog_location_diff'

Finished in 3.86 seconds (files took 6.46 seconds to load)
40 examples, 3 failures

Failed examples:

rspec ./spec/lib/extensions/ar_dba_spec.rb:11 # ar_dba extension #xlog_location_diff returns the correct xlog difference
rspec ./spec/lib/extensions/ar_dba_spec.rb:5 # ar_dba extension #xlog_location returns a valid lsn
rspec ./spec/models/pglogical_subscription_spec.rb:475 # PglogicalSubscription#backlog returns the correct value

Randomized with seed 48251

@himdel
Copy link
Contributor Author

himdel commented Jan 23, 2019

(Not sure what the plan is with 9.6+ support, but we're currently 3 versions behind, will be 4 in q4 2019.)

@JPrause
Copy link
Member

JPrause commented Jan 24, 2019

Thanks @himdel
@miq-bot remove_label stale

@miq-bot miq-bot removed the stale label Jan 24, 2019
@carbonin carbonin assigned carbonin and unassigned gtanzillo Feb 6, 2019
carbonin added a commit to carbonin/manageiq that referenced this issue Feb 7, 2019
carbonin added a commit to carbonin/manageiq that referenced this issue Feb 7, 2019
carbonin added a commit to carbonin/manageiq that referenced this issue Feb 13, 2019
carbonin added a commit to carbonin/manageiq that referenced this issue Feb 19, 2019
carbonin added a commit to carbonin/manageiq that referenced this issue Mar 11, 2019
@Fryguy Fryguy closed this as completed in d0638ea Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants