Ошибка existing state of has been invalidated

Oracle делает это, потому что перекомпиляция пакета PL / SQL делает недействительными все используемые переменные сеанса.

Мы мало что можем сделать, чтобы избежать этого, кроме как с помощью передовых методов развертывания. Не развертывайте изменения, пока база данных используется, убедитесь, что все соединения должным образом отключены и т. д. Легче сказать, чем сделать в наш век CI / CD, нулевого времени простоя и других интересных инноваций.

Итак, в задней части шкафчика есть одна вещь: pragma serially_reusable;. Эта инструкция означает, что состояние пакета сохраняется в течение один вызов сервера. Например, если у нас есть блок PL / SQL, который трижды вызывает процедуру SR, любые переменные, измененные этой процедурой, будут поддерживать значение во всех трех вызовах. Но в следующий раз, когда мы запустим блок — в том же сеансе — переменные будут сброшены до своих начальных значений.

Есть несколько ограничений для последовательного многократного использования PL / SQL — например, его нельзя использовать в SQL-запросах. Но с вашей точки зрения больше всего привлекает отсутствие ошибок ORA-04068 или ORA-04061. Нет состояния сеанса, нечего аннулировать.

pragma serially_reusable должен быть объявлен на уровне пакета, как в теле, так и в спецификации. Таким образом, вы должны быть уверены, что ни одна из упакованных процедур не должна поддерживать состояние между вызовами сервера.

On one of Oracle DB instances I am working on I am observing a different than normal behavior when recompiling packages.

Typically, (as in question Frequent error in Oracle ORA-04068: existing state of packages has been discarded) following error on first call is expected after PL/SQL package recompilation:

ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "PACKAGE.NAME" has been
invalidated
ORA-06508: PL/SQL: could not find program unit being called:
"PACKAGE.NAME"
ORA-06512: at line 1

But the second call should work fine, assuming the package has no errors of course. This behavior was present previously in that environment. In the meantime we upgraded from 11g R2 to 12c R1, and enabled edition based redefinition.

Now the problem I am experiencing is that I keep getting just:

ORA-04061: existing state of package body "PACKAGE.NAME" has been
invalidated
ORA-06508: PL/SQL: could not find program unit being called:
"PACKAGE.NAME"
ORA-06512: at line 1

So no ORA-04068 anymore, and only way to fix it is to reconnect the session or calling DBMS_SESSION.RESET_PACKAGE() manually (but I don’t control all code that may be affected anyway), otherwise the problem persists on every call.

Are there any DB parameters that control this that could got tweaked? The problem is not specific to any particular PL/SQL package and it seems that it can be triggered by normal package invalidation when something it references, changes.

Thank you in advance.

Error Message

When accessing the Spatial Type for Oracle using SQL, the following error message is displayed:

ORA-04061: existing state of has been invalidated
ORA-04061: existing state of package body «SDE.ST_GEOMETRY_SHAPELIB_PKG» has been invalidated
ORA-06508: PL/SQL: could not find program unit being called

Note:
The name of the package body (SDE.ST_GEOMETRY_SHAPELIB_PKG) may be different from time to time, but the cause of the error is the same. The error number and format of the error message will not change.

Cause

Oracle has discovered a package or type body is invalid, and the object cannot be automatically recompiled. This issue has been identified on some Oracle servers where one database object has changed and has dependent database objects which become invalid.

Solution or Workaround

The invalid object needs to be recompiled to become valid again. Oracle 10g includes a mechanism to recompile some invalid objects when they are accessed for the first time. However, this mechanism does not always work and errors of this sort can occur. If this error is encountered, the invalid packages and any invalid type bodies can be manually recompiled.

After recompiling, be sure to start a new Oracle session before verifying that recompiling solved the problem.
To find invalid objects owned by the user SDE, connect to Oracle with SQL*Plus and execute the following statement:

SELECT OBJECT_NAME, OBJECT_TYPE

FROM USER_OBJECTS

WHERE OBJECT_TYPE IN (‘PACKAGE’, ‘PACKAGE BODY’, ‘TYPE’, ‘TYPE BODY’)

AND STATUS = ‘INVALID’;

To recompile a type body, use the following command:
ALTER TYPE <object_name> COMPILE BODY;

To recompile a package body, use the following command:
ALTER PACKAGE <object_name> COMPILE BODY;

Oracle делает это, потому что перекомпиляция пакета PL / SQL делает недействительными все используемые переменные сеанса.

Мы мало что можем сделать, чтобы избежать этого, кроме как с помощью передовых методов развертывания. Не развертывайте изменения, пока база данных используется, убедитесь, что все соединения должным образом отключены и т. д. Легче сказать, чем сделать в наш век CI / CD, нулевого времени простоя и других интересных инноваций.

Итак, в задней части шкафчика есть одна вещь: pragma serially_reusable;. Эта инструкция означает, что состояние пакета сохраняется в течение один вызов сервера. Например, если у нас есть блок PL / SQL, который трижды вызывает процедуру SR, любые переменные, измененные этой процедурой, будут поддерживать значение во всех трех вызовах. Но в следующий раз, когда мы запустим блок — в том же сеансе — переменные будут сброшены до своих начальных значений.

Есть несколько ограничений для последовательного многократного использования PL / SQL — например, его нельзя использовать в SQL-запросах. Но с вашей точки зрения больше всего привлекает отсутствие ошибок ORA-04068 или ORA-04061. Нет состояния сеанса, нечего аннулировать.

Pragma serially_reusable должен быть объявлен на уровне пакета, как в теле, так и в спецификации. Таким образом, вы должны быть уверены, что ни одна из упакованных процедур не должна поддерживать состояние между вызовами сервера.

Error Message

When accessing the Spatial Type for Oracle using SQL, the following error message is displayed:

ORA-04061: existing state of has been invalidated
ORA-04061: existing state of package body «SDE.ST_GEOMETRY_SHAPELIB_PKG» has been invalidated
ORA-06508: PL/SQL: could not find program unit being called

Note:
The name of the package body (SDE.ST_GEOMETRY_SHAPELIB_PKG) may be different from time to time, but the cause of the error is the same. The error number and format of the error message will not change.

Cause

Oracle has discovered a package or type body is invalid, and the object cannot be automatically recompiled. This issue has been identified on some Oracle servers where one database object has changed and has dependent database objects which become invalid.

Solution or Workaround

The invalid object needs to be recompiled to become valid again. Oracle 10g includes a mechanism to recompile some invalid objects when they are accessed for the first time. However, this mechanism does not always work and errors of this sort can occur. If this error is encountered, the invalid packages and any invalid type bodies can be manually recompiled.

After recompiling, be sure to start a new Oracle session before verifying that recompiling solved the problem.
To find invalid objects owned by the user SDE, connect to Oracle with SQL*Plus and execute the following statement:

SELECT OBJECT_NAME, OBJECT_TYPE

FROM USER_OBJECTS

WHERE OBJECT_TYPE IN (‘PACKAGE’, ‘PACKAGE BODY’, ‘TYPE’, ‘TYPE BODY’)

AND STATUS = ‘INVALID’;

To recompile a type body, use the following command:
ALTER TYPE <object_name> COMPILE BODY;

To recompile a package body, use the following command:
ALTER PACKAGE <object_name> COMPILE BODY;

Last Published: 5/5/2016

Article ID: 000010831

On one of Oracle DB instances I am working on I am observing a different than normal behavior when recompiling packages.

Typically, (as in question Frequent error in Oracle ORA-04068: existing state of packages has been discarded) following error on first call is expected after PL/SQL package recompilation:

ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "PACKAGE.NAME" has been
invalidated
ORA-06508: PL/SQL: could not find program unit being called:
"PACKAGE.NAME"
ORA-06512: at line 1

But the second call should work fine, assuming the package has no errors of course. This behavior was present previously in that environment. In the meantime we upgraded from 11g R2 to 12c R1, and enabled edition based redefinition.

Now the problem I am experiencing is that I keep getting just:

ORA-04061: existing state of package body "PACKAGE.NAME" has been
invalidated
ORA-06508: PL/SQL: could not find program unit being called:
"PACKAGE.NAME"
ORA-06512: at line 1

So no ORA-04068 anymore, and only way to fix it is to reconnect the session or calling DBMS_SESSION.RESET_PACKAGE() manually (but I don’t control all code that may be affected anyway), otherwise the problem persists on every call.

Are there any DB parameters that control this that could got tweaked? The problem is not specific to any particular PL/SQL package and it seems that it can be triggered by normal package invalidation when something it references, changes.

Thank you in advance.

May 4, 2021

I got ” ORA-04061: Existing state of string has been invalidated ”  error in Oracle database.

ORA-04061: Existing state of string has been invalidated

Details of error are as follows.

ORA-04061: Existing state of string has been invalidated

Cause: An attempt to resume the execution of a stored procedure using the existing state
 which has become invalid or inconsistent with the stored procedure because the procedure
 has been altered or dropped.

Action: Try again; this error should have caused the existing state of all packages to be re-initialized.
Validating logfiles...done
Patch 31281355 apply (pdb pdbName): WITH ERRORS
logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/31281355/23688465/31281355_apply_xxxNov11_11_23_45.log (errors)
-> Error at line 72459: script rdbms/admin/catsnmp.sql
- ORA-04068: existing state of packages has been discarded
- ORA-04061: existing state of package body "SYS.DBMS_AQADM_SYS" has been invalidated
- ORA-04065: not executed, altered or dropped package body "SYS.DBMS_AQADM_SYS"
- ORA-06508: PL/SQL: could not find program unit being called: "SYS.DBMS_AQADM_SYS"
- ORA-06512: at "SYS.DBMS_AQADM", line 1090
- ORA-06512: at line 2

Existing state of string has been invalidated

This ORA-04061 error is related with the attempt to resume the execution of a stored procedure using the existing state which has become invalid or inconsistent with the stored procedure because the procedure has been altered or dropped.

ORA-04061 is originated from rdbms/admin/catsnmp.sql . The script “rdbms/admin/catsnmp.sql” is invalidating the SYS.DBMS_AQADM and/or SYS.DBMS_AQADM_SYS, thus resulting in datapatch failure.

One or the other pl/sql blocks must have left some state behind.

This error is typical for:
Use a package (that sets some state)
Replace a package (discard the state)
Use it again. => encountered ORA-4061 error as the state was lost.

The problem here is the package invalidation after the associated AQ sql/plb has been applied (prvtaqds.plb in this case). Making use of the package which is in invalid state often results into ORA-4061, and that’s what is observed in the sqlpatch_catcon_0.log for package DBMS_AQADM_SYS.

Unpublished BUG 32174571 – 12C TO 19.10.201104 UPGRADE FAILING WITH ORA-04061 FOR SYS.DBMS_AQADM_SYS

As a workaround =>

1. Before applying datapatch, restart your database with the underscore parameter “_srvntfn_job_deq_timeout” set to zero in init.ora of all the instances.

_srvntfn_job_deq_timeout=0

2. Also once db is started, run utlrp.sql to validate all the invalid objects before running datapatch.

3. Once datapatch installation is done, reset the underscore parameter _srvntfn_job_deq_timeout :

SQL> alter system reset "_srvntfn_job_deq_timeout" scope=both;

Solution 1 :

Please restart the database which will help to overcome the error as one or the other pl/sql blocks must have left some state behind which was causing failure.
Once the Database is restarted, no state will be discarded.

Solution 2 :

1. Apply the patch 32174571

2. Execute datapatch

Note : The bug 32174571 is fixed in 19.10 DB RU

If you got this error on Package or procedures, you should compile it as follows.

SQL> alter procedure PROCEDURE_NAME compile ;

To recompile a package body, use the following command:

ALTER PACKAGE <object_name> COMPILE BODY;

To recompile a type body, use the following command:

ALTER TYPE <object_name> COMPILE BODY;

Do you want to learn Oracle Database for Beginners, then read the following articles.

Oracle Tutorial | Oracle Database Tutorials for Beginners ( Junior Oracle DBA )

 1,908 views last month,  1 views today

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected].-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  [email protected] a mail atabilirsiniz.

  • Ошибка exe не является приложением win32 что делать
  • Ошибка exe err not found configure mp csv
  • Ошибка exe cannot find zone
  • Ошибка exception the starting row of the range is too small
  • Ошибка exception processing message c0000013 parameters 75b3bf7c 4 75b3bf7c