Description of problem: pushing a new package to a client fails Version-Release number of selected component (if applicable): spacewalk 1.2 postgresql 8.4 Fedora 14 How reproducible: always Steps to Reproduce: 1. select client to manage 2. select package to push and schedule 3. wait for the RHN TRACEBACK email to arrive Actual results: error message Expected results: package install Additional info: Looks like a malformed SQL query on the package lookup: Exception reported from testspacewalk Time: Fri Dec 31 18:43:05 2010 Exception type <class 'spacewalk.server.rhnSQL.sql_base.SQLStatementPrepareError'> Exception while handling function registration.register_osad Request object information: URI: /XMLRPC Remote Host: testclient Server Name: testspacewalk:80 Headers passed in: Accept-Encoding: identity CONTENT_LENGTH: 2299 CONTENT_TYPE: text/xml DOCUMENT_ROOT: /var/www/html GATEWAY_INTERFACE: CGI/1.1 HTTP_ACCEPT_ENCODING: identity HTTP_HOST: testspacewalk HTTP_USER_AGENT: rhn.rpclib.py/$Revision$ HTTP_X_CLIENT_VERSION: 1 HTTP_X_INFO: RPC Processor (C) Red Hat, Inc (version $Revision$) HTTP_X_RHN_TRANSPORT_CAPABILITY: follow-redirects=3 HTTP_X_TRANSPORT_INFO: Extended Capabilities Transport (C) Red Hat, Inc (version $Revision$) Host: testspacewalk PATH_INFO: QUERY_STRING: REMOTE_ADDR: 10.3.0.133 REMOTE_PORT: 56842 REQUEST_METHOD: POST REQUEST_URI: /XMLRPC SCRIPT_FILENAME: /usr/share/rhn/wsgi/xmlrpc.py SCRIPT_NAME: /XMLRPC SCRIPT_URI: http://stl-spacewalk/XMLRPC SCRIPT_URL: /XMLRPC SERVER_ADDR: 10.3.0.41 SERVER_ADMIN: root@localhost SERVER_NAME: testspacewalk SERVER_PORT: 80 SERVER_PROTOCOL: HTTP/1.1 SERVER_SIGNATURE: <address>Apache Server at testspacewalk Port 80</address> SERVER_SOFTWARE: Apache User-Agent: rhn.rpclib.py/$Revision$ X-Client-Version: 1 X-Info: RPC Processor (C) Red Hat, Inc (version $Revision$) X-RHN-Transport-Capability: follow-redirects=3 X-Transport-Info: Extended Capabilities Transport (C) Red Hat, Inc (version $Revision$) mod_wsgi.application_group: testspacewalk|/xmlrpc mod_wsgi.callable_object: application mod_wsgi.handler_script: mod_wsgi.input_chunked: 0 mod_wsgi.listener_host: mod_wsgi.listener_port: 80 mod_wsgi.process_group: mod_wsgi.request_handler: wsgi-script mod_wsgi.script_reloading: 1 mod_wsgi.version: (3, 2) wsgi.errors: <mod_wsgi.Log object at 0x7f12ebe3e630> wsgi.file_wrapper: <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7f12ebe45210> wsgi.input: <mod_wsgi.Input object at 0x7f12ef7c66b0> wsgi.multiprocess: True wsgi.multithread: False wsgi.run_once: False wsgi.url_scheme: http wsgi.version: (1, 1) Extra information about this error: SQL Error generated: ('syntax error at or near "autonomous_transaction"\nLINE 3: pragma autonomous_transaction;\n ^\n', 0, "\ndeclare\n pragma autonomous_transaction;\nbegin\n update rhnPushClient \n set name = %(name)s,\n shared_key = %(shared_key)s,\n state_id = %(state_id)s,\n next_action_time = NULL,\n last_ping_time = NULL\n where server_id = %(server_id)s;\n if sql%%rowcount = 1 then\n -- Entry successfully updated\n commit;\n return;\n end if;\n\n insert into rhnPushClient \n (id, server_id, name, shared_key, state_id)\n values (sequence_nextval('rhn_pclient_id_seq'), %(server_id)s, %(name)s, \n %(shared_key)s, %(state_id)s);\n commit;\nend;\n") Exception Handler Information Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/spacewalk/server/apacheRequest.py", line 118, in call_function response = apply(func, params) File "/usr/share/rhn/server/handlers/xmlrpc/registration.py", line 1294, in register_osad server.register_push_client() File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnServer/server_class.py", line 833, in register_push_client ret = server_lib.update_push_client_registration(server_id) File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnServer/server_lib.py", line 341, in update_push_client_registration shared_key=shared_key, state_id=state_id) File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/sql_base.py", line 166, in execute return apply(self._execute_wrapper, (self._execute, ) + p, kw) File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 262, in _execute_wrapper raise rhnSQL.SQLStatementPrepareError(0, str(e), self.sql) SQLStatementPrepareError: ('syntax error at or near "autonomous_transaction"\nLINE 3: pragma autonomous_transaction;\n ^\n', 0, "\ndeclare\n pragma autonomous_transaction;\nbegin\n update rhnPushClient \n set name = %(name)s,\n shared_key = %(shared_key)s,\n state_id = %(state_id)s,\n next_action_time = NULL,\n last_ping_time = NULL\n where server_id = %(server_id)s;\n if sql%%rowcount = 1 then\n -- Entry successfully updated\n commit;\n return;\n end if;\n\n insert into rhnPushClient \n (id, server_id, name, shared_key, state_id)\n values (sequence_nextval('rhn_pclient_id_seq'), %(server_id)s, %(name)s, \n %(shared_key)s, %(state_id)s);\n commit;\nend;\n") Local variables by frame Frame _execute_wrapper in /usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py at line 262 function = <type 'instancemethod'> <bound method Cursor._execute of <spacewalk.server.rhnSQL.driver_postgresql.Cursor instance at 0x7f13090ed518>> e = <class 'psycopg2.ProgrammingError'> syntax error at or near "autonomous_transaction" LINE 3: pragma autonomous_transaction; ^ self = <type 'instance'> <spacewalk.server.rhnSQL.driver_postgresql.Cursor instance at 0x7f13090ed518> value = <type 'str'> 65f964539e43164a66d34cc286f18a3520b0168e p = <type 'tuple'> () kw = <type 'dict'> {'state_id': 2, 'server_id': 1000010000, 'name': 'c9e3c9de6436d7c5', 'shared_key': '65f964539e43164a66d34cc286f18a3520b0168e'} key = <type 'str'> shared_key params = <type 'str'> state_id: 2,server_id: 1000010000,name: c9e3c9de6436d7c5,shared_key: 65f964539e43164a66d34cc286f18a3520b0168e Frame execute in /usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/sql_base.py at line 166 p = <type 'tuple'> () self = <type 'instance'> <spacewalk.server.rhnSQL.driver_postgresql.Cursor instance at 0x7f13090ed518> kw = <type 'dict'> {'state_id': 2, 'server_id': 1000010000, 'name': 'c9e3c9de6436d7c5', 'shared_key': '65f964539e43164a66d34cc286f18a3520b0168e'} Frame update_push_client_registration in /usr/lib/python2.7/site-packages/spacewalk/server/rhnServer/server_lib.py at line 341 server_id = <type 'int'> 1000010000 h = <type 'instance'> <spacewalk.server.rhnSQL.driver_postgresql.Cursor instance at 0x7f13090ed518> client_name = <type 'str'> c9e3c9de6436d7c5 t = <type 'instance'> <spacewalk.server.rhnSQL.sql_table.Table> instance for table `rhnPushClientState' keyed on `label' shared_key = <type 'str'> 65f964539e43164a66d34cc286f18a3520b0168e state_id = <type 'int'> 2 row = <type 'instance'> {'id': 2, 'label': 'offline', 'modified': datetime.datetime(2010, 12, 31, 11, 49, 9, 396447, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=1140, name=None)), 'name': 'offline', 'created': datetime.datetime(2010, 12, 31, 11, 49, 9, 396447, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=1140, name=None))} Frame register_push_client in /usr/lib/python2.7/site-packages/spacewalk/server/rhnServer/server_class.py at line 833 server_id = <type 'int'> 1000010000 self = <class 'spacewalk.server.rhnServer.server_class.Server'> <Server Class at 139719733854992: {'self.cert': None, 'self.server': {'info': (None, 0), 'creator_id': (1, 0), 'provision_state_id': (None, 0), 'name': ('testclient', 0), 'created': (datetime.datetime(2010, 12, 31, 14, 50, 50, 756716, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=1140, name=None)), 0), 'auto_update': ('N', 0), 'running_kernel': ('2.6.35.10-74.fc14.x86_64', 0), 'description': ('Initial Registration Parameters:\r\nOS: fedora-release\r\nRelease: 14\r\nCPU Arch: x86_64', 0), 'org_id': (1, 0), 'modified': (datetime.datetime(2010, 12, 31, 17, 22, 3, 399774, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=1140, name=None)), 0), 'server_arch_id': (1023, 0), 'secret': ('8b83636816e4cc74ad92b21e468c55d5', 0), 'last_boot': (1293556372, 0), 'digital_server_id': ('ID-1000010000', 0), 'release': ('14', 0), 'channels_changed': (datetime.datetime(2010, 12, 31, 0, 0, tzinfo=psycop! g2.tz.FixedOffsetTimezone(offset=1140, name=None)), 0), 'auto_deliver': ('N', 0), 'os': ('fedora-release', 0), 'id': (1000010000, 0), 'cobbler_id': (None, 0)}}> Frame register_osad in /usr/share/rhn/server/handlers/xmlrpc/registration.py at line 1294 self = <type 'instance'> <server.handlers.xmlrpc.registration.Registration instance at 0x7f1308e7f878> args = <type 'dict'> {'client-timestamp': 1293838893} system_id = <type 'str'> <?xml version="1.0"?>
I would note that is is PostgreSQL specific and we need to rewrite _query_update_push_client_jid in backend/server/rhnServer/server_lib.py using this guide: https://fedorahosted.org/spacewalk/wiki/PostgreSQLPortingGuide#Noautonomoustransactions
(In reply to comment #1) > I would note that is is PostgreSQL specific and we need to rewrite > _query_update_push_client_jid > in > backend/server/rhnServer/server_lib.py > using this guide: > > https://fedorahosted.org/spacewalk/wiki/PostgreSQLPortingGuide#Noautonomoustransactions OK. I don't find server_lib.py in the server. I did just update to the nightlys for 1-3-11 to kill a osad-dispatcher from eating all the postgrs processes with "in transactions"/
(In reply to comment #2) My bad. Wrong screen. Searching on a client system. I found the server_lib/py file and edited it as below (also changing out the autonomous section above the _query_update_push_client_jid ) #_query_update_push_client_jid = rhnSQL.Statement(""" #declare # pragma autonomous_transaction; #begin # update rhnPushClient # set jabber_id = :jid, # next_action_time = NULL, # last_ping_time = NULL # where server_id = :server_id; # commit; #end; #""") _query_update_push_client_jid = rhnSQL.Statement(""" update rhnPushClient set jabber_id = :jid, next_action_time = NULL, last_ping_time = NULL where server_id = :server_id; """) And updated as well: #_query_update_push_client_registration = rhnSQL.Statement(""" #declare # pragma autonomous_transaction; #begin # update rhnPushClient # set name = :name, # shared_key = :shared_key, # state_id = :state_id, # next_action_time = NULL, # last_ping_time = NULL # where server_id = :server_id; # if sql%rowcount = 1 then # -- Entry successfully updated # commit; # return; # end if; # # insert into rhnPushClient # (id, server_id, name, shared_key, state_id) # values (sequence_nextval('rhn_pclient_id_seq'), :server_id, :name, # :shared_key, :state_id); # commit; #end; #""") _query_update_push_client_registration = rhnSQL.Statement(""" update rhnPushClient set name = :name, shared_key = :shared_key, state_id = :state_id, next_action_time = NULL, last_ping_time = NULL where server_id = :server_id; insert into rhnPushClient (id, server_id, name, shared_key, state_id) values (sequence_nextval('rhn_pclient_id_seq'), :server_id, :name, :shared_key, :state_id); """)
First one is commit as 279a3453e7bf7f6321ece41868eec29190d43b8c But the second is wrong. The original code is like update if rowcount = 1 then return else # i.e. rowcount = 0 insert and your change do the insert every time, which is wrong Hmm, this may be better fix: _query_update_push_client_registration = rhnSQL.Statement(""" begin update rhnPushClient set name = :name, shared_key = :shared_key, state_id = :state_id, next_action_time = NULL, last_ping_time = NULL where server_id = :server_id; if sql%rowcount = 1 then -- Entry successfully updated return; end if; insert into rhnPushClient (id, server_id, name, shared_key, state_id) values (sequence_nextval('rhn_pclient_id_seq'), :server_id, :name, :shared_key, :state_id); end; """) and then in def update_push_client_registration, put: rhnSQL.commit() just after the lines: h = rhnSQL.prepare(_query_update_push_client_registration) h.execute(server_id=server_id, name=client_name, shared_key=shared_key, state_id=state_id) Can you please test that this work correctly as I have no time to test it?
working on this and need to clarify design goal. original code here: _query_update_push_client_registration = rhnSQL.Statement(""" declare pragma autonomous_transaction; begin update rhnPushClient set name = :name, shared_key = :shared_key, state_id = :state_id, next_action_time = NULL, last_ping_time = NULL where server_id = :server_id; if sql%rowcount = 1 then -- Entry successfully updated commit; return; end if; insert into rhnPushClient (id, server_id, name, shared_key, state_id) values (sequence_nextval('rhn_pclient_id_seq'), :server_id, :name, :shared_key, :state_id); commit; end; """) So the declare pragma line is out (oracle only). The update should only be committed if only a single row is to be processed (if sql%rowcount is oracle only, gets changed to postgres version). If more than one row or exactly 0 rows then add to rhnPushClient. My new version is: _query_update_push_client_registration = rhnSQL.Statement(""" begin; update rhnPushClient set name = :name, shared_key = :shared_key, state_id = :state_id, next_action_time = NULL, last_ping_time = NULL where server_id = :server_id; get diagnostics my_numrows := ROW_COUNT; if my_numrows = 1 then -- Entry successfully updated commit; end; end if; insert into rhnPushClient (id, server_id, name, shared_key, state_id) values (sequence_nextval('rhn_pclient_id_seq'), :server_id, :name, :shared_key, :state_id); commit; end; """) but no joy with a syntax error with get diagnostics SQL Error generated: ('syntax error at or near "get"\nLINE 11: get diagnostics my_numrows := ROW_COUNT;\n ^\n', 0, "\nbegin;\n update rhnPushClient \n set name = %(name)s,\n shared_key = %(shared_key)s,\n state_id = %(state_id)s,\n next_action_time = NULL,\n last_ping_time = NULL\n where server_id = %(server_id)s;\n\n get diagnostics my_numrows := ROW_COUNT;\n\n if my_numrows = 1 then\n -- Entry successfully updated\n commit;\n end;\n end if;\n\n insert into rhnPushClient \n (id, server_id, name, shared_key, state_id)\n values (sequence_nextval('rhn_pclient_id_seq'), %(server_id)s, %(name)s, \n %(shared_key)s, %(state_id)s);\n commit;\n end;\n") Do I need to put all of this into a plpgsql block?
OK. I reread your instructions and and tested the following: _query_update_push_client_registration = rhnSQL.Statement(""" begin update rhnPushClient set name = :name, shared_key = :shared_key, state_id = :state_id, next_action_time = NULL, last_ping_time = NULL where server_id = :server_id; get diagnostics my_numrows := ROW_COUNT; if my_numrows = 1 then -- Entry successfully updated return; end if; insert into rhnPushClient (id, server_id, name, shared_key, state_id) values (sequence_nextval('rhn_pclient_id_seq'), :server_id, :name, :shared_key, :state_id); end; """) - and - def update_push_client_registration(server_id): <snip> h = rhnSQL.prepare(_query_update_push_client_registration) h.execute(server_id=server_id, name=client_name, shared_key=shared_key, state_id=state_id) rhnSQL.commit() <snip> This generates a SQL error: SQL Error generated: ('syntax error at or near "update"\nLINE 3: update rhnPushClient \n ^\n', 0, "\nbegin\n update rhnPushClient \n set name = %(name)s,\n shared_key = %(shared_key)s,\n state_id = %(state_id)s,\n next_action_time = NULL,\n last_ping_time = NULL\n where server_id = %(server_id)s;\n\n get diagnostics my_numrows := ROW_COUNT;\n\n if my_numrows = 1 then\n -- Entry successfully updated\n return;\n end if;\n\n insert into rhnPushClient \n (id, server_id, name, shared_key, state_id)\n values (sequence_nextval('rhn_pclient_id_seq'), %(server_id)s, %(name)s, \n %(shared_key)s, %(state_id)s);\n end;\n")
fixed. tested with no errors. patch below: diff -up server_lib.py.orig server_lib.py --- server_lib.py.orig 2011-01-06 10:36:08.496183999 -0500 +++ server_lib.py 2011-01-06 14:52:59.480184002 -0500 @@ -303,8 +303,9 @@ def entitlement_grants_service(entitleme # Push client related # XXX should be moved to a different file? _query_update_push_client_registration = rhnSQL.Statement(""" +create or replace function qupcr() returns void as $_$ declare - pragma autonomous_transaction; + my_numrows integer := 0; begin update rhnPushClient set name = :name, @@ -313,9 +314,11 @@ begin next_action_time = NULL, last_ping_time = NULL where server_id = :server_id; - if sql%rowcount = 1 then + + get diagnostics my_numrows := ROW_COUNT; + + if my_numrows = 1 then -- Entry successfully updated - commit; return; end if; @@ -323,8 +326,8 @@ begin (id, server_id, name, shared_key, state_id) values (sequence_nextval('rhn_pclient_id_seq'), :server_id, :name, :shared_key, :state_id); - commit; -end; + end; +$_$ language plpgsql; """) def update_push_client_registration(server_id): # Generate a new a new client name and shared key @@ -338,6 +341,7 @@ def update_push_client_registration(serv h = rhnSQL.prepare(_query_update_push_client_registration) h.execute(server_id=server_id, name=client_name, shared_key=shared_key, state_id=state_id) + rhnSQL.commit() # Get the server's (database) time # XXX timestamp = int(time.time())
Removing from space15, this is Fedora bugzilla.
This message is a notice that Fedora 14 is now at end of life. Fedora has stopped maintaining and issuing updates for Fedora 14. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At this time, all open bugs with a Fedora 'version' of '14' have been closed as WONTFIX. (Please note: Our normal process is to give advanced warning of this occurring, but we forgot to do that. A thousand apologies.) Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, feel free to reopen this bug and simply change the 'version' to a later Fedora version. Bug Reporter: Thank you for reporting this issue and we are sorry that we were unable to fix it before Fedora 14 reached end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged to click on "Clone This Bug" (top right of this page) and open it against that version of Fedora. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete. The process we are following is described here: http://fedoraproject.org/wiki/BugZappers/HouseKeeping