Bug 1434339 - traceback when showing list of activation keys: Internal Server Error: java.lang.AssertionError: Failed to update row
Summary: traceback when showing list of activation keys: Internal Server Error: java.l...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: WebUI
Version: 570
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: Jan Dobes
QA Contact: Lukáš Hellebrandt
URL:
Whiteboard:
Depends On:
Blocks: sat580-low
TreeView+ depends on / blocked
 
Reported: 2017-03-21 10:13 UTC by Jan Hutař
Modified: 2017-06-21 12:07 UTC (History)
2 users (show)

Fixed In Version: spacewalk-schema-2.5.1-40 satellite-schema-5.8.0.25-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-06-21 12:07:33 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Jan Hutař 2017-03-21 10:13:54 UTC
Description of problem:
It is possible to get into the state when showing list of activation keys produces ISE. This issue is about ISE produced when there are duplicate values in the rhnset table.

Note the issue was discovered by pstudeni and investigated by jdobes.


Version-Release number of selected component (if applicable):
satellite-schema-5.7.0.27-1.el6sat.noarch (but others are affected as well)


How reproducible:
We were not able to reproduce it besides one case


Steps to Reproduce:
1. Unreliable reproducer:
   a. Delete lots (hundreds) of activation keys via spacecmd:
      # spacecmd -s ... -u ... -p ... activationkey_list \
          | grep "^1-" \
          | xargs spacecmd -s ... -u ... -p ... activationkey_delete -y
   b. During it is deleting, refresh Systems -> Activation keys multiple times
2. Reliable, but not real-world reproducer:
   a. To see the issue, lets break directly the DB:
      rhnschema=# INSERT INTO rhnset (user_id, label, element) VALUES (1, 'activation_keys', 123);
      rhnschema=# INSERT INTO rhnset (user_id, label, element) VALUES (1, 'activation_keys', 123);
      rhnschema=# INSERT INTO rhnset (user_id, label, element) VALUES (1, 'activation_keys', 123);
   b. Show duplicate rows:
      rhnschema=# select user_id, label, element, count(*) from rhnset group by user_id, label, element having count(*) > 1;
       user_id |      label      | element | count 
      ---------+-----------------+---------+-------
             1 | activation_keys |     123 |     3
      (1 row)
   c. Check ISE on Systems -> Activation Keys
   d. Fix it:
      rhnschema=# DELETE FROM rhnset WHERE user_id = 1 AND label = 'activation_keys' AND element = 123;
      DELETE 3


Actual results:
Problem is that when rhnset have some duplicate rows, there is a assert in the code that checks that only one row was deleted (pardon me if I reproduced what jdobes told me yesterday incorrectly).


Expected results:
Code should be able to handle this case.

Comment 1 Jan Hutař 2017-03-21 10:15:20 UTC
Incorrect unique constraint in PostgreSQL DB schema reported as bug 1434336.

Comment 2 Jan Dobes 2017-04-05 12:41:02 UTC
As bz1434336 will update existing data in rhnSet table and will prevent inserting duplicates again, it should not happen after upgrade. I think it's enough.

Comment 4 Lukáš Hellebrandt 2017-05-29 13:53:32 UTC
Verified with spacewalk-schema-2.5.1-48 and satellite-schema-5.8.0.31-1 with ManagedDB.

It is no more possible to have duplicate rows in rhnschema so it is not even possible to perform reproducer.


Note You need to log in before you can comment on or make changes to this bug.