473,396 Members | 2,052 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,396 software developers and data experts.

deadlock detected when inserting data

I am running OSDL-dbt1 - an e-commerce workload
(http://www.osdl.org/lab_activities/k...te/osdl_dbt-1/)
against PostgreSQL: 7.3.3. During the test, I saw a lot of messages in
the database log file:

NOTICE: _sc_id=0, _add_flag=0, _itemcount=0, _i_id=597, _pp_i_id=159,
c_id=32760
ERROR: deadlock detected
WARNING: Error occurred while executing PL/pgSQL function shopping_cart
WARNING: line 311 at SQL statement
WARNING: ROLLBACK: no transaction in progress

The shopping_cart transaction does update/insert to shopping_cart and
shopping_cart_line tables, and if it is a new shopping_cart, it queries
the SEQUENCE scid to get a new shopping_cart.

I tried to search the mailing list, and got the impression that if there
are foreign key related to the tables, then deadlock happens. But that
is not my case. I do not have foreign key either referring to this two
tables, or defined on those tables.

Can anyone give some suggestions how I should analyze this problem? Or
are there any documentation? I am not driving the database very hard.
The only comparison I have are the previous runs I did against SAPDB,
which performs better.

Let me know if you need more info.

TIA,

Jenny
--
Jenny Zhang
Open Source Development Lab
12725 SW Millikan Way, Suite 400
Beaverton, OR 97005
(503)626-2455 ext 31

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #1
2 8256
Thanks for your quick response.

I did take some database statistics during the run. I posted at:
http://developer.osdl.org/jenny/deadlock/db_stat/

In the db_activity?.out, all the database connections were working on
shopping_cart procedure. Also, I noticed that tran_lock?.out shows that
the same transaction(shopping_cart) requires multiple locks and not all
of them are granted. Since shopping_cart is a storedprocedure (or
function) written in plpgsql, and it calls other functions, is it
possible that the transaction is too long and holds the locks?

Another question is, I've read that "Each PL/pgSQL function is
automatically treated as a single transaction
by Postgres" at http://www.geocrawler.com/archives/3...2/6/0/9050299/
is it still true? Even though the shopping_cart function calls A and A
has BEGIN and COMMIT in it, pgsql won't commit till all the shopping_cart is done?

Thanks,
Jenny
On Mon, 2003-12-15 at 12:51, Ian Harding wrote:
Deadlocks are hard to figure out sometimes. They don't necessarily have
to do with foreign key constraints. They happen when two transactions
are waiting for each other to finish what they are doing before they
proceed. Instead of waiting forever, a deadlock is declared, and one or
the other is rolled back.

It seems odd that a test suite would have this problem. It looks like
they give informative error messages though, that should be helpful.
Also, you can turn on query logging and look at pg_stat_activity to see
what's up.

Jenny Zhang wrote:
I am running OSDL-dbt1 - an e-commerce workload
(http://www.osdl.org/lab_activities/k...te/osdl_dbt-1/)
against PostgreSQL: 7.3.3. During the test, I saw a lot of messages in
the database log file:

NOTICE: _sc_id=0, _add_flag=0, _itemcount=0, _i_id=597, _pp_i_id=159,
c_id=32760
ERROR: deadlock detected
WARNING: Error occurred while executing PL/pgSQL function shopping_cart
WARNING: line 311 at SQL statement
WARNING: ROLLBACK: no transaction in progress

The shopping_cart transaction does update/insert to shopping_cart and
shopping_cart_line tables, and if it is a new shopping_cart, it queries
the SEQUENCE scid to get a new shopping_cart.

I tried to search the mailing list, and got the impression that if there
are foreign key related to the tables, then deadlock happens. But that
is not my case. I do not have foreign key either referring to this two
tables, or defined on those tables.

Can anyone give some suggestions how I should analyze this problem? Or
are there any documentation? I am not driving the database very hard.
The only comparison I have are the previous runs I did against SAPDB,
which performs better.

Let me know if you need more info.

TIA,

Jenny
------------------------------------------------------------------------

SPAM: BAYES_00 (-5.2 points) Bayesian classifier says spam probability is 0 to 1%
Score Total: -5.2

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #2
On Mon, 2003-12-15 at 22:43, Jenny Zhang wrote:
Another question is, I've read that "Each PL/pgSQL function is
automatically treated as a single transaction
by Postgres" at http://www.geocrawler.com/archives/3...2/6/0/9050299/
is it still true? Even though the shopping_cart function calls A and A
has BEGIN and COMMIT in it, pgsql won't commit till all the shopping_cart is done?


It is true. If no transaction is already in progress, each statement is
a transaction in itself (or begins a transaction if autocommit is off).
Therefore any function must necessarily execute inside a transaction.

You cannot use BEGIN in a PL/pgSQL function to begin a transaction,
since a transaction is already in progress. In PL/pgSQL, BEGIN marks
the start of the executed code (and follows any declarations).

--
Oliver Elphick Ol************@lfix.co.uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"The fear of the LORD is the instruction of wisdom, and
before honour is humility." Proverbs 15:33

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #3

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

Similar topics

1
by: New MSSQL DBA | last post by:
I have recently been assigned to take over several MSSQL environments and found some of the existing practice confusing. As most of my previous experiences are on Oracle and Unix platform so would...
1
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into...
2
by: Sumanth | last post by:
Hi , I am trying to acquire a lock on a table A in exclusive mode, and this statement gives an error indicating a deadlock or timeout has been detected. The lock timeout value is set to 0 which...
1
by: Zubair.NET! | last post by:
In our web application we are calling different XML Webservices and make approximately 25 calls every 10 minutes. We use a separate thread to call a the webservice (Crawler) and populate our cache...
0
by: Hemant Shah | last post by:
Folks, I have been getting SQLCODE -911 while reading data from a table. When I look at the db2diag.log file I see following: 2006-10-10-14.33.13.384726-240 I127058C470 LEVEL: Warning...
3
by: kavin | last post by:
hi, can any one help me in detecting a deadlock and to clear the deadlock when it occours? how to monitor the databases for deadlocks?
4
by: raccoon | last post by:
keep getting an ora-04020: deadlock detected while trying to lock object XDB. XDNDBKDJjilnd The statement I'm trying to issue is: REVOKE execute on abc."descript_T" FROM PUBLIC; I am not...
1
by: Olav | last post by:
Does anyone know what this means? Olav ISAPI 'c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll' reported itself as unhealthy for the following reason: 'Deadlock detected'. For...
0
by: halex | last post by:
Hello, I am having deadlock problem when I have a lot of visitors on my website at the same time. I am using NetTiers templates to generate C# classes for accessing DB layer and problem is in my...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.