Skip to content

Any suggestion on tracing ORA-00001 : unique constraint (%s.%s) violated - Oracle 19c RDS - Standard Edition

0

Hi,

Database is currently Oracle19c RDS - Standard Edition The application is getting ORA-00001 : unique constraint (%s.%s) violated and we want to trace it so we can check what SQL and variable values are giving the errors. Reading on https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.Oracle.CommonDBATasks.SystemEvents.html and running

SET SERVEROUTPUT ON
EXEC rdsadmin.rdsadmin_util.list_allowed_system_events;

This ORA- error is not on the list of system events that can be set. Any suggestion on what to do to be able to turn on tracing for this error? Last resort is to ask the application vendor if they can insert alter session for the said error when they connect to the database. Unsure if doing so will generate the trace file though, will have to give it a try.

Posting here in case anyone has a done a trace of ORA- errors that are not in the list of system events that can be enabled. I can't find an example of the alter session in the AWS docs. I tested and I was able to run alter session manually but not sure if I can retrieve the trace files or do a listing of the trace file and download it. Checking the doc atm, it is 'painful' listing and looking for files :( Any help will be very much appreciated. Thanks in advance.

asked 2 years ago951 views

3 Answers
1

To trace the ORA-00001 unique constraint violation error in Oracle 19c RDS Standard Edition, you have a few options:

  1. Use the Amazon RDS function rdsadmin.rdsadmin_adrci_util.show_adrci_tracefile to list and view trace files. This function can show the contents of trace files and incident trace files under the current ADR home. You can execute this function and then use rdsadmin.rds_file_util.read_text_file to read the contents of the trace files.

  2. Enable tracing for specific sessions using standard Oracle methods. You can use PL/SQL packages like DBMS_SESSION or DBMS_MONITOR to enable tracing for individual sessions connected to your Oracle DB instance in Amazon RDS.

  3. If you need more detailed tracing, you can use the EXEC rdsadmin.manage_tracefiles.dump_systemstate command, which is the Amazon RDS equivalent of oradebug dump systemstate 266. This will generate a trace file with extensive system state information.

  4. For your specific ORA-00001 error, you can create a function-based unique index or use the NULLS NOT DISTINCT clause (if using PostgreSQL 15 or later) to help identify the source of duplicate key violations.

  5. If you're able to modify the application, you could add error handling that captures and logs the details of the ORA-00001 error, including the SQL statement and variable values.

Remember that while you can run ALTER SESSION commands, accessing the resulting trace files directly may be limited in RDS. You'll need to use the provided Amazon RDS functions to list and retrieve trace file contents.

If these methods don't provide enough information, you may need to work with AWS Support or your application vendor to find a solution that works within the constraints of RDS.
Sources
Diagnosing problems with RDS for Oracle DB instances - Amazon Relational Database Service
Amazon RDS for Oracle database log files - Amazon Relational Database Service
Migrate rows with unique constraints to Amazon RDS for PostgreSQL or Amazon Aurora PostgreSQL | AWS Database Blog

answered 2 years ago

EXPERT

reviewed 2 years ago

  • Thanks for your very helpful list of suggestions. The vendor is not helpful in troubleshooting this error. We have requested if we can incorporate STEP 2 where we can enable/disable as required. Will STEP 3 capture this unique constraint error though? Can't do STEP 4 without 'approval' from the application vendor. STEP 5 will be the best solution, if they can trap the error and insert the failing record into some exception table of some sort. AWS Support will be the last resort. IMO, AWS RDS should at least allow some user-event tracing outside of the ones that they allowed :(

0

Is this the exact error message you are getting? I mean can you paste a screenshot of the actual statement and error output generated? ORA-00001 : unique constraint (%s.%s) violated

AWS

answered 2 years ago

  • The actual error is ORA-00001: unique constraint ([OWNER].[INDEX_CONSTRAINTS_NAME]) violated} and we are able to check that this is an index as it is not found in DBA_CONSTRAINTS, only in DBA_INDEXES. I don't have access to the actual SQL that is causing the problem. Vendor is not really responsive troubleshooting hence we want to trace it ourselves instead.

0

Hi,

Indeed , the ORA-00001 is not really related to an Oracle issue but more to an application issue. Generally, the issue investigation is done on application side (enabling applicating tracing)

You can also enable it on Oracle side , even if it's a little more complicated. Bebych has provide the different ways to perfom it

I would like to add 3 others possibilities :

- 1) Trace the entire database : "alter system set sql_trace=true;"

Be careful with this solution. We will trace all sessions in database.

This solution could be use when you know how to reproduce the issue and you apply it only for fews minutes.

- 2) For client in enterprise edition with the Tuning pack , we can leverage the V$ACTIVE_SESSION_HISTORY (sample time = 1 sec)  & DBA_HIST_ACTIVE_SESS_HISTORY (sample time = 10 sec)

So depending on you execution time , the query can't be catched. As you are in standard edition it doesn't apply to you, but maybe it could help for others people.

- 3) another workaround , if your client is reactive, as every query is part of the shared memory,  he could also try to join V$SQLAREA(or V$SQL) and V$SQL_BIND_CAPTURE (if you have bind value)

to find the culprit query.

But all these solutions are only workaround and aren't 100% sure, the best way still remain to add trace on the application side

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.