ERROR: 55006: source database "template1" is being accessed by other users only with Npgsql 2.2.5

389 views
Skip to first unread message

Max Bündchen

unread,
Mar 30, 2015, 10:27:01 AM3/30/15
to npgsq...@googlegroups.com
Hello people!

I have a break from Npgsql 2.2.4.3 to 2.2.5 in my current project. The error below was triggered when I try to create a new database having a Entity Framework context in use on the same Postgre server (but a different database).

To clarify the code is something like:

Database.Setinitializer<DbMaster>(null);

...

if (!dbMaster.DbChilds.Any())
{
            using (var connection = new NpgsqlConnection(connectionStringChild))
            {
                var cmd = new NpgsqlCommand();
                cmd.Connection = connection;
                connection.Open();
                
                cmd.CommandText = "create database child1";
                cmd.ExecuteNonQuery();
            }
}

This code works fine with any version of Npgsql from 2.2.2 to 2.2.4.3 (not tested before 2.2.2, but should works too and avoid the 2.2.4.1 because Npgsql.EntityFramework) and with any version of Entity Framework from 6.0.0 to 6.1.3 (I have tested the permutations to be sure).

If I pause the execution after the first use of DbMaster (the Any() query) and try to create a database with pgAdminIII in the same server I also get this error.

------

Message: ERROR: 55006: source database "template1" is being accessed by other users

StackTrace:
   em Npgsql.NpgsqlState.<ProcessBackendResponses>d__0.MoveNext()
   em Npgsql.ForwardsOnlyDataReader.GetNextResponseObject(Boolean cleanup)
   em Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()
   em Npgsql.ForwardsOnlyDataReader.NextResultInternal()
   em Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean preparedStatement, NpgsqlRowDescription rowDescription)
   em Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)
   em Npgsql.NpgsqlCommand.ExecuteNonQuery()
   em Hgm.Gestao.Infraestrutura.BancoDados.BancoDadosHelper.CriarBdn(String sbdn, String bdn) na c:\Users\Max\Documents\Visual Studio 2013\Projects\GestaoWeb-v1a\Infraestrutura\BancoDados\BancoDadosHelper.cs:linha 46
   em Hgm.Gestao.Infraestrutura.BancoDados.BancoDadosHelper.CriarBdnSeNaoExistir(String sbdn, String bdn) na c:\Users\Max\Documents\Visual Studio 2013\Projects\GestaoWeb-v1a\Infraestrutura\BancoDados\BancoDadosHelper.cs:linha 31
   em Hgm.Gestao.Servicos.Principal.ContaServico.CriarEmpresaModeloNegocioSeNaoExistir(Guid empresaMestreId) na c:\Users\Max\Documents\Visual Studio 2013\Projects\GestaoWeb-v1a\Servicos\Principal\ContaServico.cs:linha 161
   em Hgm.Gestao.Web.Controllers.ContaController.SessaoUsuarioEmpresa(Guid empresaMestreId) na c:\Users\Max\Documents\Visual Studio 2013\Projects\GestaoWeb-v1a\Web\Controllers\ContaController.cs:linha 94
   em lambda_method(Closure , ControllerBase , Object[] )
   em System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   em System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   em System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   em System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
   em System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   em System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   em System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   em System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
   em System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   em System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   em System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()

Shay Rojansky

unread,
Mar 30, 2015, 7:21:09 PM3/30/15
to Max Bündchen, npgsq...@googlegroups.com
Max, can you please open an issue for this on http://github.com/npgsql/npgsql?

--
You received this message because you are subscribed to the Google Groups "Npgsql Help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to npgsql-help...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/npgsql-help/6c00b284-1181-43ab-b6b8-625476c28b3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages