Обсуждение: BUG #14273: Tuple concurently updated error while creating function using async call from node js with postgresq
BUG #14273: Tuple concurently updated error while creating function using async call from node js with postgresq
От
hargudekishor@gmail.com
Дата:
VGhlIGZvbGxvd2luZyBidWcgaGFzIGJlZW4gbG9nZ2VkIG9uIHRoZSB3ZWJz aXRlOgoKQnVnIHJlZmVyZW5jZTogICAgICAxNDI3MwpMb2dnZWQgYnk6ICAg ICAgICAgIEtpc2hvciBIYXJndWRlCkVtYWlsIGFkZHJlc3M6ICAgICAgaGFy Z3VkZWtpc2hvckBnbWFpbC5jb20KUG9zdGdyZVNRTCB2ZXJzaW9uOiA5LjQu OApPcGVyYXRpbmcgc3lzdGVtOiAgIFVidW50dQpEZXNjcmlwdGlvbjogICAg ICAgIAoKSGksDQoNCkkgYW0gZmFjaW5nIGEgc3RyYW5nZSBpc3N1ZSBvbiBw b3N0Z3Jlc3FsLTkuNC44Lg0KDQpiZWxvdyBpcyB0aGUgZGVzY3JpcHRpb24g b2YgdGhlIGlzc3VlLg0KDQpXZSBoYXZlIGNvbm5lY3RlZCBvdXIgbm9kZSBq cyBhcHBsaWNhdGlvbiB3aXRoIHBvc3RncmVzcWwtOS40LjguV2UgaGF2ZQpz ZXZlcmFsIGZ1bmN0aW9ucyB3aGljaCBhcmUgZ2V0dGluZyBjcmVhdGVkIGlu IGRhdGFiYXNlIHVzaW5nIGFzeW5jIGNhbGwKZnJvbSBub2RlanMgdG8gcG9z dGdyZXNxbCBzZXJ2ZXIuYnV0IHdoaWxlIGNyZWF0aW5nIHRob3NlIGZ1bmN0 aW9ucyAsV2UgYXJlCmVuY291bnRlcmVkIGEgZXJyb3Igb2YgIlR1cGxlIGNv bmN1cnJlbnRseSB1cGRhdGVkIi5BbmQgYmVjYXVzZSBvZiB0aGlzCmVycm9y IG91ciBub2RlIGpzIGFwcGxpY2F0aW9uIGlzIGdldHRpbmcgdGVybWluYXRl ZC53aGljaCBpcyBub3QgYWZmb3JkYWJsZQp0byB1cy4NCg0KQmVsb3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ygNCi4N Ci4NCi4NCi4NCg0KV2UgdHJpZWQgdG8gZXhlY3V0ZSB0aG9zZSBmdW5jdGlv biBieSBzZXR0aW5nIHRyYW5zYWN0aW9uX2lzb2xhdGlvbiB0bwpzZXJpYWxp emFibGUgYnV0IGVuY291bnRlcmVkIHNhbWUgaXNzdWUuDQoNClBsZWFzZSBz dWdnZXN0IG1lIHRoYXQsSG93IGNhbiBJIGJ5cGFzcyB0aGlzIGVycm9yLi4u T1IgaXMgaXQgYSBidWcgYWJvdXQKc2V2ZXJpdHkgb2YgbWVzc2FnZSAoInR1 cGxlIGNvbmN1cnJlbnRseSB1cGRhdGVkIilvbiB0aGlzIGtpbmQgb2YgaXNz dWUKLlNob3VsZCBpdCBiZSBvbmx5IHdhcm5pbmcgPw0KDQotLQ0KS2lzaG9y Lg0KDQoNCg0KCgo=
hargudekishor@gmail.com wrote: > We have connected our node js application with postgresql-9.4.8.We have > several functions which are getting created in database using async call > from nodejs to postgresql server.but while creating those functions ,We are > encountered a error of "Tuple concurrently updated". Yeah, this is known. We haven't worried too much, because the use case seems thin: why are you deleting and creating the function over and over? Wouldn't it be better to create the function once and be done with it? > And because of this error our node js application is getting > terminated.which is not affordable to us. Surely the application should be able to do something else upon receiving an error, rather than crashing. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Alvaro Herrera <alvherre@2ndquadrant.com> writes: > hargudekishor@gmail.com wrote: >> We have connected our node js application with postgresql-9.4.8.We have >> several functions which are getting created in database using async call >> from nodejs to postgresql server.but while creating those functions ,We are >> encountered a error of "Tuple concurrently updated". > Yeah, this is known. We haven't worried too much, because the use case > seems thin: why are you deleting and creating the function over and > over? Wouldn't it be better to create the function once and be done > with it? Note that each one of those create calls, before failing, will have had to wait for the previous updater to commit or not. We could imagine installing alternate behavior such as "don't fail if the new state of the pg_proc row is exactly what you wanted anyway"; but I do not see any useful semantics that would not involve waiting to see if the prior transaction commits. And then there's the cost of the bloat that you're creating in the pg_proc catalog. So quite aside from the possibility of a concurrent-update failure, you'd be much better off from a performance standpoint if you take the trouble to not repetitively create the same function. regards, tom lane
On Wed, Aug 3, 2016 at 3:00 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote: > hargudekishor@gmail.com wrote: > >> We have connected our node js application with postgresql-9.4.8.We have >> several functions which are getting created in database using async call >> from nodejs to postgresql server.but while creating those functions ,We are >> encountered a error of "Tuple concurrently updated". > > Yeah, this is known. We haven't worried too much, because the use case > seems thin: why are you deleting and creating the function over and > over? Wouldn't it be better to create the function once and be done > with it? Hm. These days I have been pinged regarding the fact that it is possible to reach this error on a relation that has a lot of updates and where autovacuum is made more aggressive. Well, it increases the possibility to face it. simple_heap_delete() is not used except for catalogs, so could it be related to one of the pg_stat catalogs complaining with VACUUM ANALYZE running in parallel? >> And because of this error our node js application is getting >> terminated.which is not affordable to us. > > Surely the application should be able to do something else upon > receiving an error, rather than crashing. That's for sure. A crash is a bad idea, and I recall that this is not a critical failure. -- Michael
Hi, Thanks everyone for your valuable inputs. I got it now,The issue may be happening due to pg_proc catalog table update for same function by different connection at the same time(due to async call of node js to multiple db connections for same functions creation ). -- Kishor On Wed, Aug 3, 2016 at 5:44 AM, Michael Paquier <michael.paquier@gmail.com> wrote: > On Wed, Aug 3, 2016 at 3:00 AM, Alvaro Herrera <alvherre@2ndquadrant.com> > wrote: > > hargudekishor@gmail.com wrote: > > > >> We have connected our node js application with postgresql-9.4.8.We have > >> several functions which are getting created in database using async call > >> from nodejs to postgresql server.but while creating those functions ,We > are > >> encountered a error of "Tuple concurrently updated". > > > > Yeah, this is known. We haven't worried too much, because the use case > > seems thin: why are you deleting and creating the function over and > > over? Wouldn't it be better to create the function once and be done > > with it? > > Hm. These days I have been pinged regarding the fact that it is > possible to reach this error on a relation that has a lot of updates > and where autovacuum is made more aggressive. Well, it increases the > possibility to face it. simple_heap_delete() is not used except for > catalogs, so could it be related to one of the pg_stat catalogs > complaining with VACUUM ANALYZE running in parallel? > > >> And because of this error our node js application is getting > >> terminated.which is not affordable to us. > > > > Surely the application should be able to do something else upon > > receiving an error, rather than crashing. > > That's for sure. A crash is a bad idea, and I recall that this is not > a critical failure. > -- > Michael >