SCM

[#1010870] ProcessServerMessages take all cpu time with notifications on Mono

View Trackers | Bugs | Download .csv | Monitor

Date:
2010-08-23 20:50
Priority:
3
State:
Open
Submitted by:
Tapio Haapala (burner)
Assigned to:
Nobody (None)
Npgsql Version:
2.0
Category:
Group:
Resolution:
None
Summary:
ProcessServerMessages take all cpu time with notifications on Mono

Detailed description
Version 2.0.10 (Atleast, looks that there is also some issues with older versions)
File NpgsqlConnectior
class NpgsqlContextHolder
method ProcessServerMessages

Code sniplet:

while (true)
{
Thread.Sleep(0);
//To give runtime chance to release correctly the lock. See http://pgfoundry.org/forum/message.php?msg_id=1002650 for more information.
this.connector._notificationAutoResetEvent.WaitOne();

if (this.connector.Socket.Poll(100, SelectMode.SelectRead))
{
// reset any responses just before getting new ones
this.connector.Mediator.ResetResponses();
this.state.ProcessBackendResponses(this.connector);
}

this.connector._notificationAutoResetEvent.Set();
}


There is some problem with that waiting with Mono. On windows xp this works fine but if I Install software to Ubuntu 8.04 (Mono JIT compiler version 1.2.6) or to Ubuntu 10.04 (Mono JIT compiler version 2.4.4 (Debian 2.4.4~svn151842-1ubuntu4)) that code start taking 100% cpu.
You can test this with setting notification event handler and then ExecuteNonQuery with LISTEN mynotification. That cause 100% cpu usage.
I make dirty hack (0 > 100ms sleep) to my own software but this is not good solution. I dont have mono development enviroment on linux and I dont really understand what is wrong with this loop so I cannot make real fix.

Followup

No Followups Have Been Posted

Attached Files:

Changes:

No Changes Have Been Made to This Item

Powered By FusionForge