Solved

Getting different blockid ...

Posted on 2009-04-02
4
281 Views
Last Modified: 2012-05-06
Dear All,

I am trying to generate rowid for locking sessions.
In my case, I have two session. From these two session i fired same query.

ses 1 :
MLXWTIBSLDB (IBSLDB1) SQL >select rowid,CUSTINFO_CUSTOMERID from ptest where CUSTINFO_CUSTOMERID=404591 for update;

ROWID              CUSTINFO_CUSTOMERID
------------------ -------------------
AAAfbiAABAAAMOCAAA              404591

ses 2 :

MLXWTIBSLDB (IBSLDB1) SQL >select rowid,CUSTINFO_CUSTOMERID from ptest where CUSTINFO_CUSTOMERID=404591 for update;




ses 3 :

When I checked for v$session it's showing me different block number for these sessions.

       SID ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW#
---------- ------------- -------------- --------------- -------------
       904        128738              1           50050             0
      2852        128738              1           51925             0


Also these is no block exists with number 51925 for file 1.

MLXWTIBSLDB (IBSLDB1) SQL >select SEGMENT_NAME,FILE_ID,BLOCK_ID from dba_extents where SEGMENT_NAME ='PTEST';

SEGMENT_NAME                                                                         FILE_ID   BLOCK_ID
--------------------------------------------------------------------------------- ---------- ----------
PTEST                                                                                      1      51849
PTEST                                                                                      1      51721
PTEST                                                                                      1      51593
PTEST                                                                                      1      51465
PTEST                                                                                      1      51337
PTEST                                                                                      1      51209
PTEST                                                                                      1      51081
PTEST                                                                                      1      50953
PTEST                                                                                      1      50825
PTEST                                                                                      1      50697
PTEST                                                                                      1      50569
PTEST                                                                                      1      50457
PTEST                                                                                      1      50449
PTEST                                                                                      1      50441
PTEST                                                                                      1      50049

Below are the rowid generation for ses1 and ses2:

MLXWTIBSLDB (IBSLDB1) SQL >select do.object_name,
  2  row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#, dbms_rowid.rowid_create ( 1, ROW_WAIT_OBJ#, ROW_WAIT_FILE#, ROW_WAIT_BLOCK#, ROW_WAIT_ROW# ) from v$session s, dba_objects do where sid=&a and s.ROW_WAIT_OBJ# = do.OBJECT_ID
  3  /
Enter value for a: 904
OBJECT_NAME                                                                                                                      ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW#
-------------------------------------------------------------------------------------------------------------------------------- ------------- -------------- --------------- -------------
DBMS_ROWID.ROWID_C
------------------
PTEST                                                                                                                                   128738              1           50050             0
AAAfbiAABAAAMOCAAA

MLXWTIBSLDB (IBSLDB1) SQL >select do.object_name,
  2  row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#, dbms_rowid.rowid_create ( 1, ROW_WAIT_OBJ#, ROW_WAIT_FILE#, ROW_WAIT_BLOCK#, ROW_WAIT_ROW# ) from v$session s, dba_objects do where sid=&a and s.ROW_WAIT_OBJ# = do.OBJECT_ID
  3  /
Enter value for a:2852
OBJECT_NAME                                                                                                                      ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW#
-------------------------------------------------------------------------------------------------------------------------------- ------------- -------------- --------------- -------------
DBMS_ROWID.ROWID_C
------------------
PTEST                                                                                                                                   128738              1           51925             0
AAAfbiAABAAAMrVAAA


Can you please clarify me why am getting different block id for ses1 and ses2 as I am tring to update same record.

Thanks in advance.
0
Comment
Question by:someone_genius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
schwertner earned 125 total points
ID: 24047347
The locking information is not in the data file.
It is in the dictionary that is placed in SYSTEM tablespace.
Possibly the session checks the Dictionary for locked rows.
0
 
LVL 40

Assisted Solution

by:mrjoltcola
mrjoltcola earned 125 total points
ID: 24049411
1) I will point out the answer to the 1st question, DBA_EXTENTS does not include each and every block. It includes the starting BLOCK of the extend, plus the number of BLOCKS for that extent. See below.

I cannot answer the second part about the differente blocks / rowids but I may poke around and try it myself.

select SEGMENT_NAME,FILE_ID,BLOCK_ID,BLOCK_ID+BLOCKS-1 AS END_BLOCK_ID from dba_extents where SEGMENT_NAME ='PTEST';

Open in new window

0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24049616
When I test this scenario I do not see the same results. I don't see 2 sessions waiting for the same object, I see 1. Since the 1st object acquires the lock, I don't expect to see 2 rows, only 1, which is what I get.

When I create a 3rd sessiion and try to lock the row, then I see 2 session waiting on the same block #.

I think maybe you are looking at the wrong sessions?
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question