+++ This bug was initially created as a clone of Bug #1402931 +++ Description of problem: The Oracle version of lock_counts.pkb fails to lock the server-row 'for update', which kind of defeats the whole purpose iof the proc. Fix this.
There is a further hole in the erratum that released lock_counts - specifically, the unsubscribe_server path WAS NOT COVERED, in either postgresql or oracle. This is fixed in rhn_channel.pkb in both dialects.
There is diff between new 5.8 schema and 5.7 or older schema upgraded to 5.8 (both postgres an oracle) Sources in [rhnuser@DBNAME=RHNSCHEMA] and [rhnuser@DBNAME=SPACESCHEMA_BPZS9A] --- procedure_rhn_channel_subscribe_server_server_id_in_numeric_channel_id_in_numeric_immediate_in_numeric_DEFAULT_1_user_id_in_numeric_DEFAULT_NULL_numeric_recalcfamily_in_numeric_DEFAULT_1_returns_void.1 2016-12-21 12:57:24.143602374 -0500 +++ procedure_rhn_channel_subscribe_server_server_id_in_numeric_channel_id_in_numeric_immediate_in_numeric_DEFAULT_1_user_id_in_numeric_DEFAULT_NULL_numeric_recalcfamily_in_numeric_DEFAULT_1_returns_void.2 2016-12-21 12:57:24.143602374 -0500 @@ -15,8 +15,6 @@ allowed numeric; is_fve_char char(1) := 'N'; BEGIN - perform lock_counts(server_id_in); - if user_id_in is not null then allowed := rhn_channel.user_role_check(channel_id_in, user_id_in, 'subscribe'); else @@ -59,6 +57,7 @@ THEN perform rhn_exception.raise_exception('channel_subscribe_no_family'); END IF; + perform lock_counts(server_id_in); SELECT COALESCE(org_id, (SELECT org_id FROM rhnServer WHERE id = server_id_in)) INTO server_org_id_val FROM rhnChannel --- procedure_rhn_channel_unsubscribe_server_server_id_in_numeric_channel_id_in_numeric_immediate_in_numeric_DEFAULT_1_unsubscribe_children_in_numeric_DEFAULT_0_deleting_server_numeric_DEFAULT_0_update_family_countsyn_numeric_DEFAULT_1_returns_void.1 2016-12-21 12:57:24.150602279 -0500 +++ procedure_rhn_channel_unsubscribe_server_server_id_in_numeric_channel_id_in_numeric_immediate_in_numeric_DEFAULT_1_unsubscribe_children_in_numeric_DEFAULT_0_deleting_server_numeric_DEFAULT_0_update_family_countsyn_numeric_DEFAULT_1_returns_void.2 2016-12-21 12:57:24.150602279 -0500 @@ -19,7 +19,6 @@ and label = 'rhn-satellite'; child record; BEGIN - perform lock_counts(server_id_in); FOR child IN select c.id from rhnChannel c, rhnServerChannel sc Because change in satellite-schema-5.7-to-satellite-schema-5.8/001-rhn_channel-deadlock-fix.sql.postgresql is later overwritten by satellite-schema-5.7-to-satellite-schema-5.8/007-rhn_channel-update_needed_cache-async.sql.postgresql so it is not applied in upgraded schema.