PK on tourney_holdem_hand_summary (Concurrency)

PostgreSQL is the database server used to store information. Do you have a question or are you having problem with PostgreSQL? If so, post them here.

Moderator: Moderators

PK on tourney_holdem_hand_summary (Concurrency)

Postby modemouth » Sun Aug 24, 2008 5:19 pm

I'm having an issue when 2 client machines try to import hands from Pokerstars into the same database. Almost instantly a constraint violation comes up on the tourney_holdem_hand_summary_primary_key....

Code: Select all
Error: PokerStars: Unable to import hand (#19724570850). Reason: Unable to execute query: COPY tourney_holdem_hand_summary FROM STDIN;; Reason: Fatal Error (ERROR:  duplicate key value violates unique constraint "tourney_holdem_hand_summary_primary_key" CONTEXT:

Error: PokerStars: Unable to import hand (#19724806863). Reason: Unable to execute query: COPY tourney_holdem_hand_summary FROM STDIN;; Reason: Fatal Error (ERROR:  duplicate key value violates unique constraint "tourney_holdem_hand_summary_primary_key" CONTEXT:


It would seem that PostgreSQL should be handling the issuing of a unique id_hand with each new transaction. Am I wrong in believing this? It would appear that the second transaction is attempting to commit with a id_hand that is already used. Could that be because the first transaction did not commit, or it's indices haven't been updated yet? Would changing the transaction isolation level help this? Or is this an application issue?

Does anyone have any thoughts?

Thanks,
Modemouth
modemouth
 
Posts: 2
Joined: Sun Aug 24, 2008 5:00 pm

Re: PK on tourney_holdem_hand_summary (Concurrency)

Postby keggler » Sun Aug 24, 2008 8:19 pm

reindexdb -U postgres -a

from the postgres bin folder...


susan
keggler
 
Posts: 640
Joined: Sun Jun 01, 2008 4:53 am

Re: PK on tourney_holdem_hand_summary (Concurrency)

Postby WhiteRider » Mon Aug 25, 2008 5:00 pm

It is not safe to import into a single database from two versions of PT3 at once, you can cause problems in your database, as you are seeing.
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: PK on tourney_holdem_hand_summary (Concurrency)

Postby modemouth » Mon Aug 25, 2008 9:12 pm

Thanks for the info. I definitely understand that it's not working. I'm trying to figure out why. The PostgreSQL database should be adept at handling concurrency issues. Auto importing hands from two PT3 clients simultaneously doesn't seem like an unreasonable request. I don't know if this is an issue with the database itself or is a limitation of the application itself. If it's a limitation of the application I wonder if there are any plans to look at this issue? Are you aware of any other workarounds other than manually importing?

If there is no workaround and no plans to look at this issue, it would be nice to be able to "schedule" the auto-importer to run at predetermined intervals. That way the two clients would not interfere.

Thanks,
Modemouth
modemouth
 
Posts: 2
Joined: Sun Aug 24, 2008 5:00 pm

Re: PK on tourney_holdem_hand_summary (Concurrency)

Postby WhiteRider » Tue Aug 26, 2008 4:33 am

I don't know the details of why it doesn't work safely, but as I understand it postgres isn't thread-safe (i.e. can't handle concurrent updates in separate threads of processing) and since two separate instances of PT3 are running on separate computers it's not possible to co-ordinate them.

There are plans to add some scheduling options for things like importing / refreshing stats / managing databases, etc.
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK


Return to PostgreSQL [Read Only]

Who is online

Users browsing this forum: No registered users and 0 guests