473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

getting dead locks with 2 functions

I have the following 2 functions and I'm getting deadlocks when I call
them from multiple threads. The first, I'm not sure why because I'm
doing a select for update. The second I'm doing an insert on, and I
thought insert will automatically do a lock as it inserts:

-------------FUNCTION 1: -------------

CREATE OR REPLACE FUNCTION
public.select_pend_visitation_for_unvisited_links( int4)
RETURNS SETOF record AS
'
DECLARE
urlrow RECORD;
BEGIN

FOR urlrow in EXECUTE \'SELECT * FROM "URL" WHERE visited=1::int2
LIMIT \' || $1::int4 || \'FOR UPDATE\'
LOOP
UPDATE "URL" SET visited=2 WHERE "URLID"::int8 =
urlrow."URLID"::int8;
RETURN NEXT urlrow;
END LOOP;
RETURN;
END;
'
LANGUAGE 'plpgsql' VOLATILE;

-------------FUNCTION 2: -------------

CREATE OR REPLACE FUNCTION public.add_link_to_url_table(varchar, int8,
int4, int2, bool, int2)
RETURNS void AS
'
INSERT INTO "URL"
("rootlessURLString","rootURLID","rootURLIDPartiti on","visited",
"createdAt","updatedAt","isValid","URLType")
VALUES ($1, $2, $3, $4, now(), now(), $5, $6 );
'
LANGUAGE 'sql' VOLATILE;

Thanx for the help,
amir

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #1
0 1022

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
35
by: Geronimo W. Christ Esq | last post by:
Are there any scripts or tools out there that could look recursively through a group of C/C++ source files, and allow unreferenced function calls or values to be easily identified ? LXR is handy...
6
by: John Carroll | last post by:
Is there a SQL query that can be run against a database that will give me all the details on any locks that are in place at the given time? I am interested in find the lock type and owner. Thank...
0
by: amir | last post by:
I have the following 2 functions and I'm getting deadlocks when I call them from multiple threads. The first, I'm not sure why because I'm doing a select for update. The second I'm doing an...
17
by: euan_woo | last post by:
Hi, Sometimes my program stops and when I break it I see 2 threads both waiting at a lock statement trying to lock the same object. If I look up the call stack of these threads there aren't any...
2
by: Ben.Combrink | last post by:
Hi I'm using DB2 V9.1.0 on SUSE Linux with kernel version 2.6.5. In the system I'm working on, there are several stored procedures which perform simple selects through different views. ...
12
by: better_cs_now | last post by:
Hello all, I suspect that a threading issue is leading to an object being destructed in one thread context while one of its member functions is still running in another thread context. As a...
8
by: BoneIdol | last post by:
Anyway to do it? I know you can use a variable's contents as a variable name with $$name. With something like this: <?php function foo($bar) { return $bar; } $name = foo($variable_name);
4
by: bukzor | last post by:
Does anyone have a pythonic way to check if a process is dead, given the pid? This is the function I'm using is quite OS dependent. A good candidate might be "try: kill(pid)", since it throws an...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.