RoundhousE: Configuring Database options - Alter Database

459 views
Skip to first unread message

Georg

unread,
May 24, 2011, 8:02:07 AM5/24/11
to chucknorris
Hello,

in my current project we need to use SQL Service Broker.
In order to use ServiceBroker, you have to enable it first like this:

ALTER DATABASE Mercury SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;

With roundhouse 0.5, I just added this command as one of the first in
the one time command folder.
Now in 0.7 this causes an error (see it at the end of the message). It
looks like the ROLLBACK IMMEDIATE causes the trouble. Removing the
rollback immediate causes an timeout, so this is also not an option.
Is there any alternative to use Roundhouse in order to execute alter
database statements.

2011-05-24 12:15:32,610 [ERROR] -
roundhouse.databases.sqlserver.SqlServerDatabase with provider
System.Data.SqlClient does not provide a facility for recording
scripts run at this time.
could not insert: [roundhouse.model.ScriptsRun][SQL: INSERT INTO
RoundhousE.ScriptsRun (version_id, script_name, text_of_script,
text_hash, one_time_script, entry_date, modified_date, entered_by)
VALUES (?, ?, ?, ?, ?, ?, ?, ?); select SCOPE_IDENTITY()]
2011-05-24 12:15:32,624 [ERROR] - RoundhousE encountered an error.
NHibernate.Exceptions.GenericADOException: could not insert:
[roundhouse.model.ScriptsRun][SQL: INSERT INTO RoundhousE.ScriptsRun
(version_id, script_name, text_of_script, text_hash, one_time_script,
entry_date, modified_date, entered_by) VALUES
(?, ?, ?, ?, ?, ?, ?, ?); select SCOPE_IDENTITY()] --->
System.Data.SqlClient.SqlException: A transport-level error has
occurred when sending the request to the server. (provider: TCP
Provider, error: 0 - An existing connection was forcibly closed by the
remote host.)
at System.Data.SqlClient.SqlConnection.OnError(SqlException
exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParserStateObject.WriteSni()
at System.Data.SqlClient.TdsParserStateObject.WritePacket(Byte
flushMode)
at System.Data.SqlClient.TdsParserStateObject.ExecuteFlush()
at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[]
rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest
notificationRequest, TdsParserStateObject stateObj, Boolean
isCommandProc)
at
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async)
at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result)
at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method)
at
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior)
at
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
at
NHibernate.Id.IdentityGenerator.InsertSelectDelegate.ExecuteAndExtract(IDbCommand
insert, ISessionImplementor session)
at
NHibernate.Id.Insert.AbstractReturningDelegate.PerformInsert(SqlCommandInfo
insertSQL, ISessionImplementor session, IBinder binder)
--- End of inner exception stack trace ---
at
NHibernate.Id.Insert.AbstractReturningDelegate.PerformInsert(SqlCommandInfo
insertSQL, ISessionImplementor session, IBinder binder)
at
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[]
fields, Boolean[] notNull, SqlCommandInfo sql, Object obj,
ISessionImplementor session)
at
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[]
fields, Object obj, ISessionImplementor session)
at NHibernate.Action.EntityIdentityInsertAction.Execute()
at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
at
NHibernate.Event.Default.AbstractSaveEventListener.PerformSaveOrReplicate(Object
entity, EntityKey key, IEntityPersister persister, Boolean
useIdentityColumn, Object anything, IEventSource source, Boolean
requiresImmediateIdAccess)
at
NHibernate.Event.Default.AbstractSaveEventListener.PerformSave(Object
entity, Object id, IEntityPersister persister, Boolean
useIdentityColumn, Object anything, IEventSource source, Boolean
requiresImmediateIdAccess)
at
NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object
entity, String entityName, Object anything, IEventSource source,
Boolean requiresImmediateIdAccess)
at
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent
event)
at
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent
event)
at
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent
event)
at
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent
event)
at NHibernate.Impl.SessionImpl.FireSaveOrUpdate(SaveOrUpdateEvent
event)
at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj)
at
roundhouse.infrastructure.persistence.Repository.save_or_update[T](T
item)
at roundhouse.databases.DefaultDatabase`1.insert_script_run(String
script_name, String sql_to_run, String sql_to_run_hash, Boolean
run_this_script_once, Int64 version_id)
at
roundhouse.migrators.DefaultDatabaseMigrator.record_script_in_scripts_run_table(String
script_name, String sql_to_run, Boolean run_this_script_once, Int64
version_id)
at roundhouse.migrators.DefaultDatabaseMigrator.run_sql(String
sql_to_run, String script_name, Boolean run_this_script_once, Boolean
run_this_script_every_time, Int64 version_id, Environment environment,
String repository_version, String repository_path)
at
roundhouse.runners.RoundhouseMigrationRunner.traverse_files_and_run_sql(String
directory, Int64 version_id, MigrationsFolder migration_folder,
Environment migrating_environment, String repository_version)
at roundhouse.runners.RoundhouseMigrationRunner.run()

Kind regards,
Georg

Rob Reynolds

unread,
May 24, 2011, 8:18:12 AM5/24/11
to chucknorri...@googlegroups.com
RH doesn't usually run alter database functions. That is something we could probably add to another folder as an enhancement.

I believe you would want to shift to another database like master before running alter database scripts. From looking at the issue below it really looks like it is due to the shift of using NHibernate to record scripts run - we open a second connection to the database. That second connection is not happening because of this script (which may be setting it to single user?).

Like I mentioned, it is something we can add as a known folder (just like up) to allow for alter database scripts without timing out. Would you mind filing the request? http://code.google.com/p/roundhouse/issues/list OR https://github.com/chucknorris/roundhouse/issues


--
You received this message because you are subscribed to the Google Groups "chucknorris" group.
To post to this group, send email to chucknorri...@googlegroups.com.
To unsubscribe from this group, send email to chucknorrisframe...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/chucknorrisframework?hl=en.


Reply all
Reply to author
Forward
0 new messages