-
Notifications
You must be signed in to change notification settings - Fork 874
Getting SIGSEGV on Open() with mono 4.2.1 #907
Description
After upgrading to Npgsql 3.0.4, I encountered the abovementioned exception, which was apparently raised by code which had been working properly with the old (2.2, I suppose) Npgsql version I had been using so far. It happens in a tab of an app made with MonoDevelop when the tab is being built, but it's not limited to this particular tab. Here is the code which causes trouble:
protected virtual void OnPartnerChanged (object sender, System.EventArgs e)
{
if (this.partnerEntry.Text.Length > 0) {
try {
IDbCommand cmd = this.handler.conn.CreateCommand();
cmd.CommandText = "SELECT no_deliveries AS is_blocked FROM customers WHERE person_id = " +
this.partnerEntry.Text + " UNION SELECT is_blocked FROM suppliers WHERE person_id = " +
this.partnerEntry.Text + ";";
IDataReader r = cmd.ExecuteReader(); // Here the exception is thrown.
while ((r.Read())) {
isBlocked = (bool) r ["is_blocked"];
}
r.Close();
r = null;
cmd.Dispose();
}
catch (NpgsqlException ex) {
GeneralUseDialog errorDialog = new GeneralUseDialog
("Status des Geschäftspartners konnte nicht geprüft werden. Ursache:\n" + ex.Message,
"Abfrage gescheitert", Gtk.IconTheme.Default.LoadIcon("gtk-dialog-error", 32, 0),
false);
}
}
if (isBlocked) {
GeneralUseDialog partnerIsBlockedDialog = new GeneralUseDialog
("Dieser Partner ist gesperrt.\nBestimmte Belege können daher auf diesen Partner nicht ausgestellt werden.",
"Partner gesperrt", Gtk.IconTheme.Default.LoadIcon("gtk-dialog-warning", 32, 0),
false);
}
}Here is the stack trace:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: An operation is already in progress.
at Npgsql.NpgsqlConnector.StartUserAction (ConnectorState newState) [0x00000] in <filename unknown>:0
at Npgsql.NpgsqlCommand.ExecuteDbDataReaderInternal (CommandBehavior behavior) [0x00000] in <filename unknown>:0
at Npgsql.NpgsqlCommand.ExecuteDbDataReader (CommandBehavior behavior) [0x00000] in <filename unknown>:0
at System.Data.Common.DbCommand.ExecuteReader () [0x00000] in /home/abuild/rpmbuild/BUILD/mono-3.12.1/mcs/class/System.Data/System.Data.Common/DbCommand.cs:126
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader () [0x00000] in /home/abuild/rpmbuild/BUILD/mono-3.12.1/mcs/class/System.Data/System.Data.Common/DbCommand.cs:143
at iwawi.forms.Transactions.OnPartnerChanged (System.Object sender, System.EventArgs e) [0x00070] in /home/jacek/Documents/Projects/iwawi/iwawi/forms/Transactions.cs:709
This method is part of a class named Transactions.cs, which stands for a Gtk# tab, which itself gets embedded in a window. Every tab works with its own connection object. I introduced this because most of the tabs run heavy OLTP, and I really don't wanna two transactions interfere with each other. This method is called before the tab appears on the screen, but after its Build() method has been invoked. Whilst testing this, however, only one tab (and the main window, of course) was open.
I can reproduce by 100% that this snippet of code will raise the exception, but there are also several other places (in other objects) which make the whole app crash with exactly the same exception being thrown.
What I have already tried out (but without any success) was to switch pooling off in the connection string and to insert Dispose() method calls to the command object after it has been used. No use. :-(
As several other users have made a similar experience whilst running their apps on low-end machines: My application runs on an Intel Core i7 (hexa-core) with 16 GB of RAM. The server is a PostgreSQL 9.1 running on a 6-year-old Intel Core 2 Quad Q8200 with 2 GB of RAM.
Here is the Npgsql log (as far as it goes):
2015/12/19 16:36:45.983 | Opened connection to valen:7575
2015/12/19 16:36:46.003 | Executing statement(s):
select workstation_id from workstations where lower (hostname) = 'veteran' and not_in_use = false
2015/12/19 16:36:46.007 | Executing statement(s):
select person_id, fk_department_id, now() as login_date, substring(version() for (position (',' in version())) - 1) as db_version from employees where username = 'jacek' and is_inactive = false
2015/12/19 16:36:46.717 | Opened connection to valen:7575
2015/12/19 16:36:46.717 | Executing statement(s):
select workstation_id from workstations where lower (hostname) = 'veteran' and not_in_use = false
2015/12/19 16:36:46.719 | Executing statement(s):
select person_id, fk_department_id, now() as login_date, substring(version() for (position (',' in version())) - 1) as db_version from employees where username = 'jacek' and is_inactive = false
2015/12/19 16:36:46.781 | Executing statement(s):
select property_id, text from receipt_types as r, language_pack_texts as t, language_pack_text_blocks as b, languages_view as l where t.text_id = r.fk_language_pack_text_id and t.text_id = b.fk_language_pack_text_id and l.language_id = b.fk_language_id and l.iso_code = 'DE' and for_sales = true order by sort_order
2015/12/19 16:36:46.786 | Executing statement(s):
select property_id, text from customer_types as x, language_pack_texts as t, language_pack_text_blocks as b, languages_view as l where x.fk_language_pack_text_id = t.text_id and t.text_id = b.fk_language_pack_text_id and l.language_id = b.fk_language_id and l.iso_code = 'DE'
2015/12/19 16:36:46.796 | Executing statement(s):
begin work
2015/12/19 16:36:46.797 | Executing statement(s):
insert into appdata.history values (3, 10009, 'iwawi://menus/sales/telesales', default, 'Telefonverkauf: Suchmaske')
2015/12/19 16:36:46.800 | Executing statement(s):
commit
2015/12/19 16:36:46.841 | Executing statement(s):
select uri, name from appdata.history where fk_clientapp_id = 3 and fk_user_person_id = 10009 order by creation_date
2015/12/19 16:36:46.844 | Executing statement(s):
select uri, favorite_name, accelerator from appdata.favorites where fk_clientapp_id = 3 and fk_user_person_id = 10009 order by sort_order
2015/12/19 16:36:46.847 | Executing statement(s):
SELECT 'iwawi://menus/sales/crm/follow_ups?follow_up_id=' || follow_up_id AS uri, to_char (due_date, 'DD.MM.YYYY HH24:MI:SS') AS due_date FROM follow_ups AS f, employees AS e WHERE e.person_id = f.fk_recipient_person_id AND e.username = current_user AND f.closing_date IS NULL ORDER BY due_date
2015/12/19 16:36:46.849 | Executing statement(s):
SELECT 'iwawi://popups/sales/customer_contact?contact_id=' || contact_id AS uri, to_char (next_contact, 'DD.MM.YYYY HH24:MI:SS') AS next_contact FROM customer_contacts AS f, employees AS e WHERE e.person_id = f.fk_salesman_person_id AND e.username = current_user AND f.next_contact IS NOT NULL ORDER BY next_contact
2015/12/19 16:36:49.947 | Executing statement(s):
SELECT * FROM transactions_and_receipts ('DE', False, False, False, 'sales') as (person_id integer, transaction_id bigint, title varchar, customer_reference varchar, opening_date timestamp with time zone, transaction_closing_date timestamp with time zone, receipt_id bigint, receipt_type text, creation_date timestamp with time zone, predecessor_receipt_id bigint, total_net text, total_gross text, receipt_is_closed bool, receipt_closing_date timestamp with time zone)
2015/12/19 16:36:50.120 | Executing statement(s):
SELECT property_id, text, is_forbidden_for_blocked_partners FROM receipt_types AS r, language_pack_texts AS t, language_pack_text_blocks AS b, languages_view AS v, receipt_type_privileges AS p WHERE t.text_id = r.fk_language_pack_text_id AND t.text_id = b.fk_language_pack_text_id AND v.language_id = b.fk_language_id AND p.fk_receipt_type_property_id = r.property_id AND v.iso_code = 'DE' AND p.fk_department_id IN (SELECT fk_department_id FROM employees WHERE username = current_user) AND can_be_called_directly = TRUE AND (for_internal_transactions = TRUE OR for_collection = TRUE) ORDER BY r.sort_order
2015/12/19 16:36:50.126 | Executing statement(s):
SELECT property_id, text FROM order_methods as p, language_pack_texts as t, language_pack_text_blocks as b, languages_view as l WHERE t.text_id = p.fk_language_pack_text_id AND t.text_id = b.fk_language_pack_text_id AND l.language_id = b.fk_language_id AND l.iso_code = 'DE' ORDER BY p.sort_order
2015/12/19 16:36:50.169 | Executing statement(s):
select * from transactions where transaction_id = 14