Oracle geodatabase error ORA-29955 during job scheduler execution

1005
6
02-09-2023 01:56 AM
Labels (3)
Kepa
by Esri Contributor
Esri Contributor

Hi there,

We've got a an ArcGIS Server 10.7.1 environment and an Oracle database version 19.6.0.0.0 for spatial and alphanumeric data. This database is enabled as a geodatabase using ST_GEOMETRY. There we store a materialized view (partitioned and with a spatial index) and an auxiliary table with the same configuration and attributes as the aforementioned view. Neither of them are registered in the geodatabase. In order to update the auxiliary table (with spatial index as well) we managed to develop a SQL procedure as it follows:

DROP INDEX USER.VM_SIDX_AUX;
TRUNCATE TABLE USER.VM_AUX;
INSERT INTO USER.VM_AUX  
      SELECT
        CAST(1 AS NUMBER(1))  AS part_id,
        tx.TX_NOMBRE          AS text,
        pt.SHAPE
      FROM 
        USER.AUX_POINTS pt,
        USER.AUX_TXT tx
      WHERE 
        pt.TXID = tx.OBJECTID;
COMMIT;
CREATE INDEX USER.VM_SIDX_AUX ON USER.VM_AUX ("SHAPE") INDEXTYPE IS sde.st_spatial_index PARAMETERS('st_grids=1 st_srid=4326');
ALTER TABLE USER.VM EXCHANGE PARTITION P1 WITH TABLE USER.VM_AUX INCLUDING INDEXES WITHOUT VALIDATION;

Executing the previous code on a SQL Developer session works flawlessly. We'd like to automate the execution via a job scheduler, so we prepared the following procedure:

PROCEDURE refresh_VM IS
    v_exchange_stmt varchar2(32767);
    BEGIN
      execute immediate('DROP INDEX "USER"."VM_SIDX_AUX"');
      execute immediate('TRUNCATE TABLE "USER"."VM_AUX"');
      execute immediate('ALTER SESSION ENABLE PARALLEL DML');
      INSERT INTO  "USER"."VM_AUX"  
      SELECT
        CAST(1 AS NUMBER(1))  AS part_id,
        tx.TX_NOMBRE          AS text,
        pt.SHAPE
      FROM 
        USER.AUX_POINTS pt,
        USER.AUX_TXT tx
      WHERE 
        pt.TXID = tx.OBJECTID
      COMMIT;
      execute immediate('CREATE INDEX "USER"."VM_SIDX_AUX" ON "USER"."VM_AUX" ("SHAPE") INDEXTYPE IS sde.st_spatial_index PARAMETERS(''st_grids=1 st_srid=4326'')');
      dbms_stats.gather_table_stats(ownname=> 'USER', tabname=> 'VM_AUX');
      v_exchange_stmt := 'ALTER TABLE "USER"."VM" '||
                         'EXCHANGE PARTITION P1 '||
                         'WITH TABLE "USER"."VM_AUX" '||
                         'INCLUDING INDEXES WITHOUT VALIDATION';
      execute immediate (v_exchange_stmt);

    END refresh_VM;

The procedure works well too on an active SQL Developer session executing manually the job on the console, i.e.:

BEGIN
    DBMS_SCHEDULER.RUN_JOB(job_name => '"USER"."DBMS_JOB$_2"', USE_CURRENT_SESSION => TRUE);
END;

 

The problem arises when running the procedure directly from the job scheduler without being on an active SQL Developer session. The exact output is:

ERROR: ERROR IN REFRESH_VM: In exchange partition of USER.VM_AUX by USER.VM.P1 ORA-29955: an error occurred during execution of routine ODCIINDEXEXCHANGEPARTITION
ORA-20083: Parameter ST_SRID does not exist in ST_SPATIAL_REFERENCES table.
ORA-06512: in "SDE.SPX_UTIL", line 1232
ORA-06512: in "SDE.ST_DOMAIN_METHODS", line 2822
ORA-06512: in line 2

But this only happens when trying to create the spatial index. If you use the procedure to create an index on any other attribute or field it perfectly works from the job scheduler. Additionally, we set proper permissions over any SDE object for the user which executes the job (i.e. DBA_JOB_USER) and the "USER" which owns the table:

select distinct 'grant all on "SDE"."'||object_name||'" to "{DBA_JOB_USER|USER}" ;'
from dba_objects 
where owner = 'SDE'
and object_type in ('PACKAGE BODY',
                    'TYPE BODY',
                    'INDEXTYPE',
                    'PACKAGE',
                    'FUNCTION',
                    'LIBRARY',
                    'SEQUENCE',
                    'TYPE',
                    'OPERATOR',
                    'TABLE',
                    'VIEW')
;

We would appreciate if someone could shed some ligth on this particular issue. Thanks,

Kepa

0 Kudos
6 Replies
Bud
by
Notable Contributor

Side question:

Are you saying you have a materialized view on a table that has an SDE.ST_GEOMETRY column? I didn’t think that was possible. I thought object types like SDE.ST_GEOMETRY weren’t supported by MVs.

Unable to create an Oracle materialized view containing an ST_Geometry attribute

Materialized view with FAST refresh on remote table: How to include a SHAPE column?

Oracle MV requires object type to be defined as FINAL?

 

Kepa
by Esri Contributor
Esri Contributor

Not sure about your comment @Bud . I'll ask the dba and post it here. The table otherwise is created as ST_Geometry, that's for sure.

Kepa
by Esri Contributor
Esri Contributor

Just to clarify your question, dba told us MVs use ST_Geometry type.

0 Kudos
Bud
by
Notable Contributor

@Kepa  Good to know, although surprising.

@MarceloMarques might be surprised to hear this too?

0 Kudos
MarceloMarques
Esri Regular Contributor

Hello @Kepa,

Please ask your Oracle Database Administrator to look into these Oracle Support Articles below.

MOS: OERR: ORA-29955 "error occurred in the execution of ODCIINDEXEXCHANGEPARTITION routine" Reference Note (Doc ID 173670.1)

MOS: Cannot exchange table partition with Text index created before 11.2.0.3 upgrade (Doc ID 1482041.1)

This problem looks to me more of an Oracle issue than an Esri Geodatabase issue.

I recommend you open a ticket with Oracle Support first.

You can also post the question at https://community.oracle.com/mosc and see if anyone replies.

Thanks,

| Marcelo Marques | Principal Product Engineer | Esri |
| Cloud & Database Administrator | OCP - Oracle Certified Professional |
I work with Enterprise Geodatabases since 1997.
“ I do not fear computers. I fear the lack of them." Isaac Isimov
0 Kudos
Kepa
by Esri Contributor
Esri Contributor

Hello @MarceloMarques,

Thanks for your comment! Actually we've been talking to an Oracle consultant which has been working with this issue following the error traceback.

1) Going to line 2822 on SDE.ST_DOMAIN_METHODS function we see:

-- get info --
    optype := SDE.spx_util.st_geom_operation_create;
    rc := SDE.spx_util.get_object_info(ia,optype,NULL,spx_info_r,sp_ref_r,properties);

2) Then, on line 1232 under SDE.SPX_UTIL function we get the error message:

rc := SDE.st_spref_util.select_spref(spref_r);

If rc <> se_success THEN raise_application_error (SDE.st_type_util.spx_no_srid,'Parameter ST_SRID '||spref_r.srid||
                                 ' does not exist in ST_SPATIAL_REFERENCES table.');
End If;

  And finally analyzing SDE.ST_SPREF_UTIL.SELECT_SPREF, which outputs NO_DATA_FOUND

Cursor c_sel_spref (srid_in IN srid_t) IS
  SELECT sr_name,x_offset,y_offset,xyunits,z_offset,
              z_scale,m_offset,m_scale,min_x,max_x,min_y,max_y,
              min_z,max_z,min_m,max_m,cs_name,cs_type,organization,
              org_coordsys_id,Definition,description,cs_id
         FROM SDE.st_spatial_references
   WHERE srid = srid_in;

What really puzzles me is why the procedure works inside a SQL Developer session.

Anyway, I'll talk to the dba and pass the information you pointed out and hope for the best. Thanks,

 

0 Kudos