Bug #16

CreateUninitializedItem(...) throws ProviderException

Added by Christoffer Timm over 2 years ago. Updated about 2 years ago.

Status:Resolved Start:09/14/2009
Priority:Urgent Due date:01/28/2010
Assigned to:Daniel Nauck % Done:

100%

Category:Session-State Store Spent time: 2.00 hours
Target version:2.0

Description

While using PgSessionStateStoreProvider we're receiving an ProviderException sporadically. As far as we could figure out, this happens after not using the session for a longer time.

(Please find the exception details and stack trace attached.)

We checked the PostgreSQL (version 8.3.3) log and noticed, that the Provider tries to insert an already existing session, twice:

2009-06-17 17:00:17 CEST ERROR:  duplicate key value violates unique constraint "sessions_pkey" 
2009-06-17 17:00:17 CEST STATEMENT:  INSERT INTO "Sessions" ("SessionId", "ApplicationName", "Created", "Expires", "Timeout", "Locked", "LockId", "LockDate", "Data", "Flags") Values ($1::varchar(80), $2::varchar(255), $3::timestamptz, $4::timestamptz, $5::int4, $6::bool, $7::int4, $8::timestamptz, $9::text, $10::int4)
2009-06-17 17:00:17 CEST ERROR:  duplicate key value violates unique constraint "sessions_pkey" 
2009-06-17 17:00:17 CEST STATEMENT:  INSERT INTO "Sessions" ("SessionId", "ApplicationName", "Created", "Expires", "Timeout", "Locked", "LockId", "LockDate", "Data", "Flags") Values ($1::varchar(80), $2::varchar(255), $3::timestamptz, $4::timestamptz, $5::int4, $6::bool, $7::int4, $8::timestamptz, $9::text, $10::int4)

The current Provider configuration in web.config:

<sessionState mode="Custom" customProvider="PgSessionStateStoreProvider">
      <providers>
        <clear/>
        <add name="PgSessionStateStoreProvider" type="NauckIT.PostgreSQLProvider.PgSessionStateStoreProvider" enableExpiredSessionAutoDeletion="true" expiredSessionAutoDeletionInterval="60000" enableSessionExpireCallback="false" connectionStringName="AspSQLProvider" applicationName="XXX"/>
      </providers>
    </sessionState>

Any idea if this is due to a Provider issue or whether we have to blame ourselves for misconfiguration?

Thank you for having a look at this,
cti

SessionStateProvider-ProviderException.txt - ProviderException (1.9 KB) Christoffer Timm, 08/03/2009 12:18 pm

PgSessionStateStoreProvider.cs.patch - A possible Patch to fix this issue (69.9 KB) Christoffer Timm, 08/13/2009 02:50 pm

Associated revisions

Revision b24ef5058333adbf7d367d5237405b2727afda7b
Added by Daniel Nauck about 2 years ago

Bug #16: CreateUninitializedItem(...) throws ProviderException

PostgreSQL is missing a InsertOrUpdate method so
try to insert first. If the insert failed due an already existing session id try
to update the database record. if this also fails, e.g. due session cleanup tasks, try
insert a new record again.
Try the whole process 10 times before give up.

Fixes #16

History

Updated by Daniel Nauck over 2 years ago

Can you also please post he "<authentication .." block from your web.config

Updated by Christoffer Timm over 2 years ago

Replying to [comment:1 dna]:

Can you also please post he "<authentication .." block from your web.config

Here you are:

<authentication mode="Forms">
      <forms name=".AspNetAuth" protection="All" defaultUrl="~/Default.aspx" cookieless="UseCookies" loginUrl="~/MyAccount.aspx" timeout="30" path="/" requireSSL="false" slidingExpiration="true"/>
    </authentication>

Updated by over 2 years ago

We are seeing the exact same thing, using the latest from SVN. Thanks!
Roger

Updated by over 2 years ago

Same here.
This happen because:
- the web site has been just restarted (for example caused by an application-recycle): this cause (of course) to create a session marked as "new".
- the session-id of the browser as the same.
- the session provider try to insert the session in the table, but it still exist.

A solution can be to avoid the create of the state (physically the record on the table) and use the one persisted: this is also help to keep the session state when the application restart (impossible when use in-proc session mode).

best regards
michele

Updated by Daniel Nauck over 2 years ago

Ok, thanks for the feedback. I'm working on this.

Updated by Christoffer Timm over 2 years ago

Regarding the chat I had with dna this morning, I added a patch that might fix this problem. (Or at least it might be a work-around.) Please find it attached.

As for us it seemed to work properly.

Best regards,
cti

Updated by Daniel Nauck over 2 years ago

  • Status changed from New to Assigned
  • Priority changed from High to Urgent
  • Start set to 09/14/2009

Updated by Daniel Nauck about 2 years ago

  • Due date set to 01/28/2010
  • % Done changed from 0 to 100

Hello,

fixed the issue. Please try the latest build from my build server http://build.nauck-it.de

Updated by Daniel Nauck about 2 years ago

  • Status changed from Assigned to Resolved

Status geƤndert durch Changeset b24ef5058333adbf7d367d5237405b2727afda7b.

Also available in: Atom PDF