Ravendb database export/import issue in versioning - ravendb

We are using RavenDB 2.0 and bundle 2330.
We have a problem in export/import of versioned documents. We did the following.
We had a database with versioning bundle enabled
We had a number of records with multiple versions
exported the database to a dump file using Raven-Studio
Tried importing the same in another server with versioning bundle
But the server refused to import the documents and gave error as follows and stopped Import
Server sent:
at Raven.Studio.Infrastructure.InvocationExtensions.Catch(Task
parent, Func2 func) at
Raven.Studio.Infrastructure.InvocationExtensions.Catch(Task parent,
Action1 action) at
Raven.Studio.Commands.ImportDatabaseCommand.<>c_DisplayClass8.b_1()
at System.Threading.Tasks.Task.InnerInvoke() at
System.Threading.Tasks.Task.Execute() at
System.Threading.Tasks.Task.ExecutionContextCallback(Object obj) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task&
currentTaskSlot) at
System.Threading.Tasks.Task.ExecuteEntry(Boolean
bPreventDoubleExecution) at
System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch() at
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Client side exception: System.Net.WebException:
[HttpWebRequest_WebException_RemoteServer] Arguments: NotFound
Debugging resource strings are unavailable. Often the key and
arguments provide sufficient information to diagnose the problem. See
http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.20513.0&File=System.Windows.dll&Key=HttpWebRequest_WebException_RemoteServer
at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult
asyncResult) at System.Func2.Invoke(T arg) at
System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult
iar, Func2 endFunction, Action1 endAction, Task`1 promise)
So we removed the versioning bundle and then imported and then applied the versioning bundle.
The import was successful. But all the versions of the documents are being treated as separate documents and not as different version
We are on our alpha stage and suddenly recovering such issues in RavenDB. Any ideas please?

Muthu,
Do Following Steps :
Go to your database where you find list of tables.
click check all to select all the tables.
select export option from dropdown.That will export your tables.
Now create new database where you want all that record
Go inside that database (select database name.)
Go to Import tab.
Now create zip of that exported file. If your server allow simple upload then you can do that also.
Upload that zip/sql exported
your tables are ready to use.
Tell me its working for you or not?

Related

Unable to upgrade/import a dacpac file

ORIGINAL QUESTION:
Trying to upgrade a blank database created in a test VM using a .dacpac file, but get the following error message:
Error SQL72014: .Net SqlClient Data Provider: Msg 15401, Level 16, State 1, Line 1 Windows NT user or group 'SOURCE_DOMAIN\SOURCE SQL Readers' not found. Check the name again.
Error SQL72045: Script execution error. The executed script:
CREATE LOGIN [SOURCE_DOMAIN\SOURCE SQL Readers]
FROM WINDOWS WITH DEFAULT_LANGUAGE = [us_english];
(Microsoft.SqlServer.Dac)
------------------------------
Program Location:
at Microsoft.SqlServer.Dac.DeployOperation.ThrowIfErrorManagerHasErrors()
at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass14.<>c__DisplayClass16.<CreatePlanExecutionOperation>b__13()
at Microsoft.Data.Tools.Schema.Sql.Dac.OperationLogger.Capture(Action action)
at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass14.<CreatePlanExecutionOperation>b__12(Object operation, CancellationToken token)
at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.DeployOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken)
at Microsoft.SqlServer.Dac.DacServices.InternalDeploy(IPackageSource packageSource, Boolean isDacpac, String targetDatabaseName, DacDeployOptions options, CancellationToken cancellationToken, DacLoggingContext loggingContext, Action`3 reportPlanOperation, Boolean executePlan)
at Microsoft.SqlServer.Dac.DacServices.Deploy(DacPackage package, String targetDatabaseName, Boolean upgradeExisting, DacDeployOptions options, Nullable`1 cancellationToken)
at Microsoft.SqlServer.Management.Dac.DacWizard.UpgradeModel.RunAction()
at Microsoft.SqlServer.Management.Dac.DacWizard.ExecuteDacPage.backgroundWorker1_DoWork(Object sender, DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
Assuming that user existed in the source, but not in the destination. Will creating that user on the VM fix this issue or will I need to use a different approach to get the schema data from the source re-created in a VM destination for testing purposes?
UPDATE TO QUESTION 1:
The .dacpac file is generated on a server which is on a totally different domain and it will not be possible for the test VM to ever be on the same domain. With that in mind, how do I get the .dacpac file to work on the test VM?
If you still have access to VM, you could generate .dacpac again this time ignoring the logins. Depending which tool you use you should have access to option like "Include User Login Mapping".
The most roboust one has the VS: "How to create DACPAC file?" by Kamil Nowinski:
Image source: https://sqlplayer.net/wp-content/uploads/2018/10/visual-studio-extract-dacpac-options.png
You could recreate the proper logins and users afterwards with own SQL script.
Related: Using Publish Profiles to Deploy a DACPAC Database Without User Accounts
The solution to this problem lies in defining an appropriate publish profile for your DACPAC, which then instructs your chosen deployment tool – SQLPackage.exe, Visual Studio, or Azure DevOps – on how to carry out the deployment
The profile is defined as an XML file.
ExcludeUsers
ExcludeLogins
ExcludeDatabaseRoles
By setting these options to True within our publish profile, creation or modification of these objects will be skipped entirely during any database deployment.
One more option is to use dbtools.io - Export-DbaDacPackage
Key point here is:
$exportProperties = "/p:IgnorePermissions=True /p:IgnoreUserLoginMappings=True" # Ignore
and publish.xml:
...
<ExcludeLogins>True</ExcludeLogins>
<IgnorePermissions>True</IgnorePermissions>
<IgnoreLoginSids>True</IgnoreLoginSids>
<IgnoreRoleMembership>True</IgnoreRoleMembership>
Summary:
create a dacpac without login
create a publish.xml file that will ignore permissions
Creating the user inside the VM is one way to solve this issue, but you will need to change 'SOURCE_DOMAIN' to the VM hostname, as the user will be part of the local user database.
Probably the best solution is to fix VM communication to the Domain Controller, so authentication will work and user accounts end up being actually visible within the VM.
Take a look at this,
This error usually occurs because of COMPATIBILITY_LEVEL
I would recommend trying this quarry out:
ALTER DATABASE database_name
SET COMPATIBILITY_LEVEL = 130;
Hope it helps!
If a dacpac contains users or groups that aren’t on the domain where the dacpac is being deployed, then one way to deploy it is using the SqlPackage command line tool, as this allows you to explicitly list the object types you want to exclude.
To exclude users and groups, the PowerShell command would be something like this:
.\SqlPackage.exe `
/a:Publish `
/tsn:"(localdb)\mssqllocaldb" `
/tdn:YourDatabaseName `
/p:ExcludeObjectTypes="Users;RoleMembership;Logins;ServerRoles;ServerRoleMembership;Permissions" `
/sf:YourFile.dacpac
This command uses the following switches:
/a (Action): the action to run, in this case Publish
/tsn (TargetServerName): the name of the server to deploy to
/tdn (TargetDatabaseName): the name of the database to deploy to
/p (Properties): name value pair of action-specific properties, in this case:
ExcludeObjectTypes: a semicolon-delimited list of object types that should be ignored
/sf (SourceFile): the dacpac file to deploy
More details of the syntax for Publish (including a list of the object types that can be exlcuded) are available in the docs for the publish action.

ravendb remove multiple versions of the same document

I have a database with version bundle turned on. So the documents were saved like:
user/1/revision/1, user/1/revision/2, etc.
But what I didnt expect is that on search I will have all the versions of the same user or whatever else document I deal with.
I tried to restore this db to a new database with version bundle turned on and off and I still have all the versions in search.
I make search like this:
session.Query<Entity>().Search(x=>x.Name, query, options: SearchOptions.And, escapeQueryOptions: EscapeQueryOptions.AllowPostfixWildcard)
Not sure, maybe I should use some specific parameters to work with latest document version only?
UPDATE:
What I did so far:
reinstalled ravendb and installed it as a service(it was as a service, just made sure I didnt break anything)
imported data from old database to new database
deleted all the indexes related to the entity
I still get all the revisions in my search results. Also my Raven.Server.config doesnt have anything related to bundles. My raven version is 2750 which seem to be the latest production release recommended.
UPDATE 2: When I try to import data to new database from old dump I get the following error:
Client side exception:
System.Exception: Server Error:
/bulk_docs
Raven.Abstractions.Exceptions.OperationVetoedException: PUT vetoed by Raven.Bundles.Versioning.Triggers.VersioningPutTrigger because: Modifying a historical revision is not allowed
at Raven.Database.DocumentDatabase.AssertPutOperationNotVetoed(String key, RavenJObject metadata, RavenJObject document, TransactionInformation transactionInformation)
at Raven.Database.DocumentDatabase.<>c_DisplayClass4b.b_43(IStorageActionsAccessor actions)
at Raven.Storage.Esent.TransactionalStorage.Batch(Action1 action)
at Raven.Database.DocumentDatabase.Put(String key, Etag etag, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation)
at Raven.Database.Extensions.CommandExtensions.Execute(ICommandData self, DocumentDatabase database, BatchResult batchResult)
at Raven.Database.DocumentDatabase.ProcessBatch(IList1 commands)
at Raven.Database.DocumentDatabase.<>c_DisplayClass10c.b_108(IStorageActionsAccessor actions)
at Raven.Storage.Esent.TransactionalStorage.ExecuteBatch(Action1 action, EsentTransactionContext transactionContext)
at Raven.Storage.Esent.TransactionalStorage.Batch(Action1 action)
at Raven.Database.DocumentDatabase.Batch(IList`1 commands)
at Raven.Database.Server.Responders.DocumentBatch.Batch(IHttpContext context)
at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx)
at Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx)
Any ideas how to fix it?
Revisions shouldn't be indexed. As long as the versioning bundle is active on the database and the revision documents have a metadata key Raven-Document-Revision-Status with value Historical they should be ignored by all indexed.
Check the bundle is active on that DB, and the metadata mentioned above exists.
This holds true for 2.0, 2.5 and iirc 1.0 as well.

NHibernate - Cannot set the ConfigurationCache property after calling Init

In my S#arp Arch 2.0 project, I'm communicating with 2 databases. This runs fine locally with the ASP.Net Development Server (VS 2010) and passes unit tests requiring talking to either database.
Next step was to Publish the project (using VS' built-in "Publish" menu option) to the in-house development server (Windows Server 2008 R2) and fire this thing up on a real server where people could actually see it.
Now I get the exception shown in the title when I try to run the application. The exception is thrown at the = new NHibernateConfigurationFileCache() line below:
private void InitialiseNHibernateSessions()
{
NHibernateSession.ConfigurationCache = new NHibernateConfigurationFileCache();
NHibernateSession.InitStorage(this.webSessionStorage);
NHibernateSession.AddConfiguration(NHibernateSession.DefaultFactoryKey,
new[] { Server.MapPath("~/bin/SRN2.Infrastructure.dll") },
new AutoPersistenceModelGenerator().Generate(),
Server.MapPath("~/NHibernate.config"),
null, null, null);
NHibernateSession.AddConfiguration(SRN2.Infrastructure.DataGlobals.OTHER_DB_FACTORY_KEY,
new string[] { Server.MapPath("~/bin/SRN2.Infrastructure.dll") },
new AutoPersistenceModelGenerator().Generate(),
Server.MapPath("~/NHibernate-OTHER.config"),
null, null, null);
}
Stack trace:
[InvalidOperationException: Cannot set the ConfigurationCache property after calling Init]
SharpArch.NHibernate.NHibernateSession.set_ConfigurationCache(INHibernateConfigurationCache value) +105
SRN2.Web.Mvc.MvcApplication.InitialiseNHibernateSessions() in C:\code\SRN2-Sharp2\trunk\Solutions\SRN2.Web.Mvc\Global.asax.cs:122
SharpArch.NHibernate.NHibernateInitializer.InitializeNHibernateOnce(Action initMethod) +116
SRN2.Web.Mvc.MvcApplication.Application_BeginRequest(Object sender, EventArgs e) in C:\code\SRN2-Sharp2\trunk\Solutions\SRN2.Web.Mvc\Global.asax.cs:71
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Jon is right, it does sound like your InitialiseNHibernateSessions method is being called multiple times. You don't have to use the config cache, have you tried disabling it?
The NHibernate configuration is cached to file in order to improve start up time. If the configuration has not changed it is loaded from the cache file. The default location of the cache file is the system temporary file folder (e.g. Path.GetTempPath()).
If you don't have file permissions, or don't need config caching, just remove or comment out the line that initialises the configuration cache, i.e. this line:
NHibernateSession.ConfigurationCache = new NHibernateConfigurationFileCache();
This error occurred, for one application, roughly every month or two months for an extended period. I haven't really been able to fix this permanently but I did discover that the following procedure resolves the error for:
Delete the temporary configuration cache files; they should be located in the Windows temporary files folder and there should be a file for each database (e.g. DatabaseName--1973822310.bin) and another named something like nhibernate.current_session--1973822310.bin.
Restart the IIS web site for your application.
Recycle the application pool for your application.

Trouble creating the DNN Survey Module from source code

My boss has asked me to set up DotNetNuke's Survey Module and make a few custom changes to it for a client. But I'm having trouble just getting the bare-bones code to run properly!
Here's what I've done so far:
Downloaded both the source & install folders from
http://dnnsurvey.codeplex.com/releases/view/65186
Created a new VB Web Application Project
Took out all the default pages
Copied the Survey source code into the VB Web Application Project in exactly the same structure
Made a batch script that creates an installation folder identical to DNN's install folder (double-checked by running a folder-diff on it, and all files/folders were identical)
Zipped up my installation folder using 7-zip
The source code compiles perfectly. But even though the files/folders are identical, DNN's zipped package will work properly on my DNN site, and my own zipped package will fail with this famous error message:
Error: Survey is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: Could not load type 'DotNetNuke.Modules.Survey.survey'. ---> System.Web.HttpParseException: Could not load type 'DotNetNuke.Modules.Survey.survey'. ---> System.Web.HttpParseException: Could not load type 'DotNetNuke.Modules.Survey.survey'. ---> System.Web.HttpException: Could not load type 'DotNetNuke.Modules.Survey.survey'. at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplateParser.ParseInternal() at System.Web.UI.TemplateParser.Parse() at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType() at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at DotNetNuke.UI.ControlUtilities.LoadControl[T](TemplateControl containerControl, String ControlSrc) at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---
I've already asked about this on the DNN forums, but they don't have much to say about it :( So, I thought I'd try StackOverflow as well.
Does anybody have any idea what the problem could be? Thanks very much in advance!
If you want to create package, correctly, you have to first install the module that you have in your dnn instance. Once you are done with that, you did the right job till step4. After step 4 I generally do following:
Go to project properties, and point the bin directory path to parent dnn installation's bin directory
Add reference of dotentnuke.dll and microsoft data acecss application blogs dll
Rebuild the project
Once you can correctly compile the app, you are ready to customize it.
Always use dnn's module create wizard to create package. it is easier and error free way of packaging and delivering the modules.
let me know if you need any other help
I ended up solving this one on my own. These are the steps I took:
Removed all Namespace DotNetNuke.Modules.Survey declaractions
Deleted the ascx, ascx.vb, and designer files for survey, Settings,
and EditSurvey
Created new, empty ones with those names (but used "Survey" instead
of "survey")
Copied/pasted the ascx code into each ascx file (and changed
DotNetNuke.Modules.survey to DotNetNuke.Modules.Survey)
Did a build
Copied/pasted the ascx.vb code into each ascx.vb file (and removed
the Namespace declarations in these files)
Did a build, which was 100% successful this time
Bizarre way to solve the problem, but it worked. :3

nHibernate: Unable to locate persister

Running VS2003, nHB 3.0.0.3001, trying to run a unit test through Gallio 3.2. The code is from the first session of "Summer of nHibernate". I am getting the following error when attempting to run the test.
NHibernate.HibernateException: Unable to locate persister: DataTransfer.Customer
TargetSite: Void OnLoad(NHibernate.Event.LoadEvent, NHibernate.Event.LoadType)
HelpLink: null
at NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType)
at NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType)
at NHibernate.Impl.SessionImpl.Get(String entityName, Object id)
at NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id)
at NHibernate.Impl.SessionImpl.Get[T](Object id)
at DataAccessLayer.NhibernateDataProvider.GetCustomerById(Int32 customerId)
My very uneducated guess is that the Customer class cannot be seen. But both the unit test and the data access layers have a reference to the DataTransfer assembly that holds the Customer class. The Customer class is public and all the properties are public virtual.
The nHB config file is in the directory, and the Customer mapping file is an embedded resource. Seems to fail on the
line:
return session.Get<Customer>(customerId);
Make sure your mapping file is named *.hbm.xml
Make sure it is set to an embedded resource.
If these fail, debug and when it fails, catch the exception and look at the InnerException - NHibernate has fantastic error messaging hidden in there.
Hope those thigs help out - otherwise we can look into some other options (but 1 and 2 solve 90% of persister problems)
I'm using ActiveRecord for entity mapping, got the same error when tried to use ISession.Get,
instead of using configuration for retrieving session, like this:
ISession session = new NHibernate.Cfg.Configuration()
.Configure()
.AddAssembly(typeof(Account).Assembly)
.SetInterceptor(new SqlStatementInterceptor())
.BuildSessionFactory().OpenSession();
I changed it to work through ActiveRecordMediator:
ISession session = Castle.ActiveRecord.ActiveRecordMediator
.GetSessionFactoryHolder().
CreateSession(typeof(Castle.ActiveRecord.ActiveRecordBase));
now its working great..
On your hibernate.cfg.xml file, add this code:
<mapping assembly="(name of your Assembly Project)" />
Basically, on your code its:
<mapping assembly="DataTransfer" />