Deadlock when executing package simultaneously from two different sessions
I have written a package which will do the below tasks .
package A
Delete data which was older than one year from master table A and then populate data from stage table A to master table A .
truncate summary table and populate the summary table from the master table .
The package will be executed from a java application with the help of a scheduler in java. Some times, the packageA is still executing, while another instance of the package A is scheduled, that creating to deadlock in oracle. we can not use dbms_locks pkg in our application due to restrictions . i want to handle this situation from the db side in such way that the session B , need to wait until the session A completes the execution of the package . Can some one please tell how to handle this scenario in pl/sql?
I thought of creating a function which will return the execution status of package A by reading a flag from temporary table . So that next schedule can be scheduled with the return status of the function. is there any other way other than this , so that i can pause execution of package A in session B and resume after session A is successfully executed
create or replace pkg a
populate master ;
populate smry ;
populate app_tables ;
end pkg ;
create or replace pkg body
populate master()
delete from master where loaddate < sysdate -365;
loop
fetch from stage a
insert to master a
end loop
populate smry()
truncate sumary a ;
insert into smry
select values from master ;
populate app_tables()
populate master;
populate smry ;
end pkg body
I have a question about your requirements. I'm not questioning them just trying to understand them. You wrote:
Delete data which was older than one year from master table A and then populate data from stage table A to master table A .
truncate summary table and populate the summary table from the master table . If this is all there is to the requirement why would a second invocation be scheduled so soon? If you delete all data older than one year why would you need to do it again so soon?
Notwithstanding the above you basically need a serialization management process.
For all batch frameworks I have worked with we always include batch control and status tables to:
1. guarantee that batches are run in the proper order
2. allow for batch restart
3. allow for suspension or termination of single batch jobs or job streams
4. provide for reporting of batch statistics - batch run time, records processed, etc.
5. simplify the testing of complex batch streams. Tests can be performed on any one batch step or any combination of steps by enabling/disabling flags in the control tables.
6. eliminate the possibility of the problem you are reporting
Using one or more batch control and status tables, in my opiinion, is the simplest and best way to serialize the batch jobs you are dealing. Such tables gives you maximum flexibility while placing the fewest constraints on the system.
In the system I work with we try to have a clear line of demarcation between processes that control the work to be done and the processes that actually do the work.
The processes that do the work never determine what data they work with; they are parameterized so that they are told what data to use. All they know is how to process the data that they are told to process. This makes it easier to scale to add additional 'worker' processes by having the 'control' processes break up the data into different batches and running 'worker's in parallel.
I would suggest designing and implementing a control hierarchy to oversee the execution of the worker processes. This will be your serialization manager.
Similar Messages
-
Not able to compare PL/SQL body from two different offline database object
It is not possible to compare two package bodies from two different off line database object in two different off line database and schema.
JDeveloper display a compare not available message in the middle of the window.
It is possible to compare the package specification.Not able to compare scripts generated from offline database objects too
-
Possible solution to avoid deadlock when two inserts happen on same table from two different machines.
Below are the details from deadlock trace.
Deadlock encountered .... Printing deadlock information
Wait-for graph
NULL
Node:1
KEY: 8:72057594811318272 (ffffffffffff) CleanCnt:3 Mode:RangeS-S Flags: 0x1
Grant List 2:
Owner:0x00000013F494A980 Mode: RangeS-S Flg:0x40 Ref:0 Life:02000000 SPID:376 ECID:0 XactLockInfo: 0x000000055014F400
SPID: 376 ECID: 0 Statement Type: INSERT Line #: 70
Input Buf: RPC Event: Proc [Database Id = 8 Object Id = 89923542]
Requested by:
ResType:LockOwner Stype:'OR'Xdes:0x0000002AA53383B0 Mode: RangeI-N SPID:238 BatchID:0 ECID:0 TaskProxy:(0x00000027669B4538) Value:0x10d8d500 Cost:(0/38828)
NULL
Node:2
KEY: 8:72057594811318272 (ffffffffffff) CleanCnt:3 Mode:RangeS-S Flags: 0x1
Grant List 2:
Owner:0x0000000B3486A780 Mode: RangeS-S Flg:0x40 Ref:0 Life:02000000 SPID:238 ECID:0 XactLockInfo: 0x0000002AA53383F0
SPID: 238 ECID: 0 Statement Type: INSERT Line #: 70
Input Buf: RPC Event: Proc [Database Id = 8 Object Id = 89923542]
Requested by:
ResType:LockOwner Stype:'OR'Xdes:0x000000055014F3C0 Mode: RangeI-N SPID:376 BatchID:0 ECID:0 TaskProxy:(0x000000080426E538) Value:0x30614e80 Cost:(0/41748)
NULL
Victim Resource Owner:
ResType:LockOwner Stype:'OR'Xdes:0x0000002AA53383B0 Mode: RangeI-N SPID:238 BatchID:0 ECID:0 TaskProxy:(0x00000027669B4538) Value:0x10d8d500 Cost:(0/38828)
deadlock-list
deadlock victim=process5daddc8
process-list
process id=process5daddc8 taskpriority=0 logused=38828 waitresource=KEY: 8:72057594811318272 (ffffffffffff) waittime=2444 ownerId=2994026815 transactionname=user_transaction lasttranstarted=2014-07-25T12:46:57.347 XDES=0x2aa53383b0 lockMode=RangeI-N schedulerid=43 kpid=14156 status=suspended spid=238 sbid=0 ecid=0 priority=0 trancount=2 lastbatchstarted=2014-07-25T12:46:57.463 lastbatchcompleted=2014-07-25T12:46:57.463 clientapp=pa hostname=pa02 hostpid=1596 loginname=myuser isolationlevel=serializable (4) xactid=2994026815 currentdb=8 lockTimeout=4294967295 clientoption1=671088672 clientoption2=128056
executionStack
frame procname=mydb.dbo.SaveBill line=70 stmtstart=6148 stmtend=8060 sqlhandle=0x03000800d61f5c056bd3860170a300000100000000000000
INSERT INTO [dbo].[Prod1] .....
inputbuf
Proc [Database Id = 8 Object Id = 89923542]
process id=process5d84988 taskpriority=0 logused=41748 waitresource=KEY: 8:72057594811318272 (ffffffffffff) waittime=2444 ownerId=2994024748 transactionname=user_transaction lasttranstarted=2014-07-25T12:46:57.320 XDES=0x55014f3c0 lockMode=RangeI-N schedulerid=39 kpid=14292 status=suspended spid=376 sbid=0 ecid=0 priority=0 trancount=2 lastbatchstarted=2014-07-25T12:46:57.440 lastbatchcompleted=2014-07-25T12:46:57.440 clientapp=pa hostname=pa01 hostpid=1548 loginname=myuser isolationlevel=serializable (4) xactid=2994024748 currentdb=8 lockTimeout=4294967295 clientoption1=671088672 clientoption2=128056
executionStack
frame procname=pa.dbo.SaveBill line=70 stmtstart=6148 stmtend=8060 sqlhandle=0x03000800d61f5c056bd3860170a300000100000000000000
INSERT INTO [dbo].[Prod1]....
inputbuf
Proc [Database Id = 8 Object Id = 89923542]
resource-list
keylock hobtid=72057594811318272 dbid=8 objectname=pa.dbo.prod1 indexname=PK_a id=lock1608ee1380 mode=RangeS-S associatedObjectId=72057594811318272
owner-list
owner id=process5d84988 mode=RangeS-S
waiter-list
waiter id=process5daddc8 mode=RangeI-N requestType=convert
keylock hobtid=72057594811318272 dbid=8 objectname=pa.dbo.prod1 indexname=PK_a id=lock1608ee1380 mode=RangeS-S associatedObjectId=72057594811318272
owner-list
owner id=process5daddc8 mode=RangeS-S
waiter-list
waiter id=process5d84988 mode=RangeI-N requestType=convertDon't know. Perhaps these can help. I scanned the second link but didn't see much about Ending Deadlocks. I'd say the Fourth link probably has better information than the first three links. But maybe read them all just in case the Fourth is missing something
one of the first three have.
Deadlocking
Detecting and Ending Deadlocks
Minimizing Deadlocks
Handling Deadlocks in SQL Server
Google search for "SQL Deadlock"
La vida loca -
Is it possible to load an IPAD from two different ITune accounts? When I try it says it'll delete all the other account first.
This is correct.
Ipad wilol sync itunes content and pics with one and only one computer at a time. Syncing to another will erase the current content. -
Revision: 21394
Revision: 21394
Author: [email protected]
Date: 2011-06-16 12:34:13 -0700 (Thu, 16 Jun 2011)
Log Message:
bug fix for watson 2887837 Not getting duplicate session detected error when same flex client id is used from two different HTTP sessions in CRX.
get the sessions id before we invalidate the duplicate session.
Checkintests pass
Modified Paths:
blazeds/trunk/modules/core/src/flex/messaging/endpoints/BaseHTTPEndpoint.javaFor our profect I think this issue was caused as follows:
Believing that remoting was full asynchronous we fired a 2 or 3 remote calls to the server at the same time ( within the same function ) - usually when the users goes to a new section of the app.
This seemed to trigger the duplicate http session error since according to http://blogs.adobe.com/lin/2011/05/duplication-session-error.html two remote calls arriving before a session is created will cause 2 sessions to be created.
Our current solution ( too early to say it works ) is to daisy chain the multiple calls together .
Also there seemed to be an issue where mobile apps that never quit ( thanks Apple! ) caused the error when activated after a few hours.
I guess the session expires on the server and the error above occurs on activation.
So the mobile apps now ping the server with a remote call when activated after sleeping for more than one hour.
All duplicate http errors are silently caught and reported.
Fingers crossed we won't get any more! -
Table transformation from two different database
Hi all,
I am trying to load table from one database table to another database table in ODI 10g.I have created two physical and logical topology.
But when in interface design i have drag the source and target tables in the diagram window, but here it doesnot shows the auto mapping options, when i try it manually by dragging a field, i have failed. when i execute the operation the following error occured:
create or replace view db1."C$_0 W_INT_ORG_D"
as select
from db1.W_INT_ORG_DS W_INT_ORG_DS
where (1=1)
here both the source and target db are same..
How can i resolve itHi,
Thanks it worked.
I am getting another error on Insert flow into I$ table step.
I am connecting two database from two different hosts, both are in oracle.
I have two logical schema prepared for both database.
should i have to mentioned these schema in one physical topology? what should be placed in schema and work schema option.
I have used LKM Oracle to Oracle(DBLINK) as KM.
Please help
Best regards,
manish -
APEX Application accessing data from two different databases
Hi All,
Currently as we all know that APEX Application resides in database and is connected to the schema of that database.
I want APEX Application to be running and accessing data from two different databases. Elaborating my question,
Currently, my APEX Production Application is connected with XXXX Schema of DB1 Database(Where APEX Resides). Now I want to add some pages into this APEX Application for REPORT Purpose, But I want to connect this REPORT APEX Pages to get data from Different Schema YYYY for Database DB2.
Is it possible to configure this scenario?
The reason for doing this is to avoid the REPORT related (adhoc queries) resource utilization effect on Production DB1 Database.
Thanks
Nil1. If you do the joining of two or more tables in DB1 then all data is pulled over to DB1 and then the join is executed: so more data over the databaselink and more work for DB1. Better keep the joining stuff where the data resides and just pull exactly that data over that you need.
2. Don't know about your different block sizes. Seems a nice question for one of the other forums (DBA or SQL).
3. I mean create synonyms on DB1 for reports VIEWS in DB2.
Hope all is clear! -
Can I use the same Apple ID for iMessage and FaceTime services simultaneously on two different devices - iPhone and iPad? It seems those are competing to each other, and the services work on one of them only (iPhone).
Many thanks, Sir! Both are mine and it's good to know that imessage can work on both with the same Apple ID. Will now have to find out why imessage stopped working on iPad when it started on iPhone (new). After exploring the forum I understand that there may be plenty of reasons why imessage does not work, even though it worked previously on the same device with the same ID.
-
Downloading songs from two different computers, and not recognizing songs
On my home computer, I downloaded about 40 songs onto my IPod from CDs. Then, I installed the program on my work computer, and purchased four songs from ITunes. When I plug my IPod into my work computer, it is not recognizing the songs I downloaded from my home computer. However, if I plug my IPod into my work computer, I can listen to these four purchased songs, but once I try to listen to them without having it plugged into my work computer, only the songs I downloaded from home are on the IPod.
Has this happened to anyone else who has tried to put songs from two different computers onto their IPod?Just to elaborate a bit, you need to copy the purchased files and put them on your home computer.
Don't burn them as an audio CD as you will lose quality when you re-import them.
You can use the Shuffle (instead of a CD) to do this
Check out this link.
http://docs.info.apple.com/article.html?artnum=61131 -
How can I transfer songs from two different itunes?
I want to transfer songs from my brother's itunes library to my shuffle, but when I plug it in his computer, a message saying that his library is not linked to my library (or something to that extent) and whether I would like to replace the songs. If I click yes, all my existing songs are replaced with HIS songs. If I click on NO, the Shuffle icon does not appear at all and I cannot transfer any of his songs to my shuffle. How can I transfer songs from two different computers into my shuffle without replacing any of my existing music?
Shuffle Windows XP
Windows XPYou'll have to setup your iPod to manual instead of automatic update (I'm not sure, though, if it works with the Shuffle as well).
Alexander. -
Dear all:
I want to write VB programs to sample data simultaneously from two channels in PCI 5922. The niscope driver has some example VB programs to sample data from one channel, for example, the "save to file ", the program works well to sample the data from one channel. When I modify it to sample data simultaneously from two channels, I always get error so I seek your help on how to write the program to sample two channels simulatenously. Thanks. I attached the sample program here and what I tried to modify is the "channel name" and "waveform()"
Regards
Andy
Attachments:
savetofile.doc 42 KBHi Bajaf, regarding the FFT of the four channels, the next link might be what your looking for:
http://digital.ni.com/public.nsf/allkb/862567530005f09c8625671b00739970
Respect the phase issue how are you doing the acquisition of the signals, are you doing two independent acquisitions? if you are controlling them as independent acquisitions try to synchronize them with triggers and the clock.
How much are they out of phase?
By the way we know have forums in Spanish
Best Regards
Benjamin C
Senior Systems Engineer // CLA // CLED // CTD -
How to calculate AGE from two different date fields
hi
I need to calculate AGE from two different date fields.
Can some help me how to do, when i try to do substraction formula it is showing error.
Thank You
ManuManu wrote:
Hi
Both fields are in date format only, i need to calculate no . of days between two different dates
Thanks
ManuThe reason for the question about the format of the column is because the simplest solution only works on DATE columns. Others have mentioned this here, but if you want the difference between two date fields, you can use this formula:
TIMESTAMPDIFF(SQL_TSI_DAY, date_column1, date_column2)
The above being said, you still didn't tell me what you did, or what error message you received. So again, if the above formula didn't work, what did you do? Where did you put the formula? What was the exact syntax you used? What was the error message you got?
Please don't make us work more than we need to. Answer all the questions in your next post. Thanks. -
Getting DISTINCT count from two different columns
Hi all,
I have following query which gives currency code from two different tables. I would like to get the distinct count of currency codes from these two different columns.
SELECT eb.person_seq_id, eb.bonus_amount, eb.currency_cd, ed.currency_cd_host
FROM fr_emp_bonuses eb, fr_emp_details ed, fr_periods p
WHERE eb.person_seq_id = ed.person_seq_id AND ed.period_seq_id = eb.period_seq_id
AND ed.period_seq_id = p.period_seq_id AND p.period_status = 'CURRENT'
AND eb.bonus_amount >= 0 AND eb.person_seq_id = 3525125;
This query gives following result
3525125 240000 USD INR
3525125 0 USD INR
3525125 60000 USD INR
3525125 50000 USD INR
There are two distinct currency codes (USD, INR) and total amount is 350000. So I am looking for a query to give me the following result
3525125 350000 2
Thanks in advanceHi,
Here's one way:
WITH original_query AS
SELECT eb.person_seq_id
, eb.bonus_amount
, eb.currency_cd
, ed.currency_cd_host
FROM fr_emp_bonuses eb
, fr_emp_details ed
, fr_periods p
WHERE eb.person_seq_id = ed.person_seq_id
AND ed.period_seq_id = eb.period_seq_id
AND ed.period_seq_id = p.period_seq_id
AND p.period_status = 'CURRENT'
AND eb.bonus_amount >= 0
AND eb.person_seq_id = 3525125
, unpivoted_data AS
SELECT person_seq_id
, bonus_amount
, currency_cd
FROM original_query
UNION ALL
SELECT person_seq_id
, 0 AS bonus_amount
, currency_cd_host AS currency_cd
FROM original_query
SELECT person_seq_id
, SUM (bonus_amount) AS total_bonus_amount
, COUNT (DISTINCT currency_cd) AS distinct_currency_cds
FROM unpivoted_data
GROUP BY person_seq_id
;There may be a shorter, more efficient way to get the same results, but without knowing more about your tables, I can't tell.
The tricky thing is getting two columns (currency_cd and currencuy_cd_host in this case) counted together. You can't simply say
COUNT (DISTINCT eb.currency_cd) +
COUNT (DISTINCT ed.currency_code_host)That happens to get the correct result with the sample data you posted, but what if you had data like thEe following?
currency_cd currency_cd_host
INR USD
USD INRHere, the count of distinct currency_cds is 2, and the count of distinct currency_cd_hsots is also 2. Does that mean the grand total is 2 + 2 = 4? No, the 2 codes in one column arte the same 2 codes as in the other column. We need to get both currency_cd and currency_cd_hsot into the same column, and then do COUNT (DISTINCT ...) on that combined column. A UNION, as shown above, will certainly do that, starting with your query as you posted it. The query you posted isn't necessarily the best frist step towards this result, however, so there may be a much better approach, depending on your tables.
Edited by: Frank Kulash on Feb 1, 2012 6:21 PM
Here's a slightly shorter, and probably more efficient way to get the same results:
WITH cntr AS
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= 2
SELECT eb.person_seq_id
, SUM (eb.bonus_amount) AS total-amount
, COUNT ( DISTINCT CASE
WHEN c.n = 1
THEN eb.currency_cd
ELSE ed.currency_cd_host
END
) AS distinct_currency_cds
FROM fr_emp_bonuses eb
, fr_emp_details ed
, fr_periods p
, cntr c
WHERE eb.person_seq_id = ed.person_seq_id
AND ed.period_seq_id = eb.period_seq_id
AND ed.period_seq_id = p.period_seq_id
AND p.period_status = 'CURRENT'
AND eb.bonus_amount >= 0
AND eb.person_seq_i = 3525125
-- NOTE: no join condition involving c; we really do want a cross-join
GROUP BY eb.person_seq_id
; -
How to handle an update of the same record from two different user JSP
how do you handle an update of the same record from two different users in JSP... if one person updates the record from one drop downs should be updated as well.. is the possible.
I'm not sure whether I understand your question. If one user changes a record then you would like other users to see those changes. Normally those changes will be visible to other users when they refresh their browser, after the first user has committed changes to the record. I you want to be sure that the same row isn't updated at the same time by to different user, you need to configure some locking (pessimistic locking) - this depends of what technology you use. In EJB3 pessimistic locking is performed by adding a version to every entity object. If you are using ADF, the framework is able to handle either pessimistic or even optimistic locking.
If you want the changed row to be updated in other users browsers without any user interaction by these users, you should take a look at Reverse Ajax (ex. DWR http://ajaxian.com/archives/reverse-ajax-with-dwr) - or Ajax in general. But you will never get a realtime solution, where changes is visible in other users browsers right after each record update. -
How to handle an update of the same record from two different user in JSP
how to handle an update of the same record from two different user
how do you handle an update of the same record from two different users in JSP... if one person updates the record from one drop downs should be updated as well.. is the possible.Usually, if two users try to update the same row at the same time, you want the first to commit to succeed, and when the second commits, they should fail with the error that the row was being concurrently updated. They you may want to show them the new row values and give them the opportunity to merge their values with the new row values...
How can you achieve this? Google optimistic locking.
Maybe you are looking for
-
What are Logical patha nd physical paths?
Hi all, When i am uploading Material master data through LSMW i am getting Error like The Logical file name LSMW_* ....is not created. What are this Logical files and i know these are Created by FILE tCode. My question is why we need this file and it
-
Radio station playlist not showing up in Playlist folder
Hello, I am using iTunes 10.2.1.1 I have a Playlist Folder titled Night. In this folder i have a Smart Playlist containing any podcasts where plays = 0. This allows me to listen to all of my new podcasts for each day. Also in the Folder is a playlist
-
[images with serial numbers removed]
-
ASO data loading...
<p> </p><p>hi,</p><p>i have a big problem...pls help me...</p><p>i had a rule file in essbase 6.5 for BSO but now i have migratedthe same outline to 7.2.now my rule file is giving me problem whileloading data</p><p>i am loading data for member Days w
-
Update field "Country of origin" in Product Master in SAP EWM system.
Hi Team I have a requirement like as follows: I need to update the country of origin (HERKL) field into the product master transaction /SAPAPO/MAT1 ( Tab: Properties Field name Ctry of Origin) through BAPI. So i want to know what is the BAPI Name to