Memory Optimized Database recovery - sql

There's situation when my database(with memory optimized tables) has gone into 'Recovery Pending' state. I tried to put it into
emergency mode-->Single User Mode--> DBCC CHECKDB(<DBName>)--->set it online--->Multiuser mode.
But I am facing below error message while doing ONLINE mode.
Msg 5181, Level 16, State 5, Line 9 Could not restart database
"DBName". Reverting to the previous status. Msg 5069, Level 16, State
1, Line 9 ALTER DATABASE statement failed. Msg 41316, Level 23, State
3, Line 3395 Restore operation failed for database 'DBName' with
internal error code '0x0000000a'
I tried to check SQL error Log file and there's below message.
[ERROR] Database ID: [6] ''. Failed to load XTP checkpoint. Error
code: 0x88000001.
(d:\b\s2\sources\sql\ntdbms\hekaton\sqlhost\sqlmin\hkhostdb.cpp : 5288
- 'HkHostRecoverDatabaseHelper::ReportAndRaiseFailure')
And Rebuilding log file for Memory Optimized database is also not supported. Does anyone know familiar with such error?

Related

Error in unserialize(rx_model): read error

I've created a model in R, published into SQL Server table and validated the model by calling it into SQL Server. However, I am failing to execute model stored procedure in SQL server.
I get this error message:
Msg 39004, Level 16, State 20, Line 2
A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 2, Line 2
An external script error occurred:
Error in unserialize(rx_model) : read error
Calls: source -> withVisible -> eval -> eval -> unserialize
Error in execution. Check the output for more information.
Error in eval(expr, envir, enclos) :
Error in execution. Check the output for more information.
Calls: source -> withVisible -> eval -> eval -> .Call
Execution halted
Tried this;
model <- unserialize(rx_model);
or
model <- unserialize(as.raw(rx_model));
also tried;
model = unserialize(rx_model);
Still getting same error.
New to R/ML in SQL Server, help would be appreciated

What's the wrong with this code?

I'm new in SSMS, and I'm trying to execute this code:
use master
create database SQL20145Db2
on primary
( name = Sql2015Data2, filename='C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Sql2015Data2',
size=4MB, MaxSize=15, FileGrowth= 20%
)
log on
(Name=Sql2015Log2, filename='C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Sql2015Log2',
size= 1MB,MaxSize=5Mb,filegrowth=1MB
)
But the messages pane displays this error:
Msg 5123, Level 16, State 1, Line 2
CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Sql2015Data2'.
Msg 1802, Level 16, State 4, Line 2
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
This error happen because the registry value DefaultData and DefaultLog (which correspond to default data directory) are either empty or does not exists.
See documentation for more information.
Most of the time, these registry values does not exists because they actually need to be accessed as Admin. So, to fix this issue, simply run whatever application you are using to execute the sql as an administrator.

Perl DBI treats setting SQLite DB cache_size as a write operation when subclassing DBI

I have a Perl program that we have run successfully every day for almost the past 2 years, but which crashes today with the error message:
FATAL ERR: Can't do PRAGMA cache_size = 1000000: attempt to write a readonly database
The SQLite database in question is readonly, and always has been, and the code has always used PRAGMA cache_size = 1000000 on it immediately after opening its readonly connection.
Setting cache_size is not a write operation, and does not fail if I access the db directly thru the DBI, like this:
$dbh->do("PRAGMA cache_size = 1000000")
However, the code makes SqliteH::db a subclass of DBI::db, then calls this function from the subclass:
$self->SUPER::do("PRAGMA cache_size = 1000000")
and it now dies with "DBD::SQLite::db do failed: attempt to write a readonly database at /local/ifs_projects/prok/function/src/lib/SqliteH.pm line 329."
The code worked with CentOS 5, Perl 5.10.1, DBD::SQLite 1.29, and DBI 1.611.
It does not work CentOS 6, Perl 5.16, DBD::SQLite 1.39, and DBI 1.627.
I am however mystified that it /did/ work last week on CentOS 6 and Perl 5.16. IT may have upgraded DBD::SQLite or DBI over the weekend.
Please do not change the title to "Suddenly getting error on program that has worked for months" again. That is an unhelpful and nonspecific title.
TL;DR - if transactions are on, then any command attempts to write to the transaction log. Remove AutoCommit=>0 from the dbh connection flags if the database is read-only [You shouldn't have any ->begin_work() or INSERT/UPDATE calls either, but that never worked on a read-only db :-) ].
As it turns out, I had exactly the same problem today after updating SQLite, DBI and DBD::SQLite (so I don't know exactly which of them caused the problem), but in my case, on a select (which made it even more baffling).
It turned out that transactions were turned on in the original connect string:
my $dbh=DBI->connect('dbi:SQLite:file.db','','',, {PrintError=>1,RaiseError=>1,AutoCommit=>0});
and, after tracing the code, I noticed that it was actually crashing trying to start a transaction.
DB<4> $dbh->trace(15)
DBI::db=HASH(0x18b9c38) trace level set to 0x0/15 (DBI # 0x0/0) in DBI 1.627-ithread (pid 15740)
DB<5> $sth= $dbh->prepare("SELECT key,value FROM annotation where accession=?")
...
DB<6> $sth->execute('D3FET3')
-> execute for DBD::SQLite::st (DBI::st=HASH(0x18ba340)~0x18ba178 'D3FET3') thr#10cd010
sqlite trace: bind into 0x18ba268: 1 => D3FET3 (0) pos 0 at dbdimp.c line 1232
sqlite trace: executing SELECT key,value FROM annotation where accession=? at dbdimp.c line 660
sqlite trace: bind 0 type 3 as D3FET3 at dbdimp.c line 677
sqlite trace: BEGIN TRAN at dbdimp.c line 774
sqlite error 8 recorded: attempt to write a readonly database at dbdimp.c line 79
!! ERROR: '8' 'attempt to write a readonly database' (err#1)
<- execute= ( undef ) [1 items] at (eval 15)[/usr/local/packages/perl-5.16.1/lib/5.16.1/perl5db.pl:646] line 2 via at -e line 1
DBD::SQLite::st execute failed: attempt to write a readonly database at (eval 15)[/usr/local/packages/perl-5.16.1/lib/5.16.1/perl5db.pl:646] line 2.
...
Removing the AutoCommit=>0 flag in the connect() call fixed my problem.

verifyonly error message

I use following sql statement
RESTORE VERIFYONLY FROM DISK = 'F:\testBackup\test_2013-01-18.BAK'
GO
I get this error while doing so:
Attempting to restore this backup may encounter storage space problems. Subsequent messages will provide details.
The path specified by "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\test.mdf"
is not in a valid directory.
Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\test_log.ldf"
failed with the operating system error 3(failed to retrieve text for this error. Reason: 15100).
Msg 3189, Level 16, State 1, Line 1
Damage to the backup set was detected.
Msg 3013, Level 16, State 1, Line 1
VERIFY DATABASE is terminating abnormally.
How do I fix this?
Try to use this:
RESTORE VERIFYONLY
FROM DISK = 'F:\testBackup\test_2013-01-18.BAK'
WITH NORECOVERY,
MOVE 'test_Data'
TO '<YourPath>\test.mdf',
MOVE 'test_Log'
TO '<YourPath>\test_log.ldf';
And you can check MSDN site to further advices.

Restore database in SQL Server 2005

BACKUP DATABASE [MPRM] TO DISK = N'\\rauf\shared\MPRM_15_5_10.BAK'
WITH NOFORMAT, NOINIT, NAME = N'MPRM-Full Database Backup',
SKIP, NOREWIND, NOUNLOAD, STATS = 10
The backup process worked, and I got a file named MPRM_15_5_10.BAK in my shared folder (D:\shared\). This is a backup created from another machine.
When I try to restore the backup, using the following script
RESTORE DATABASE [MPRM]
FROM DISK = N'\\rauf\shared\MPRM_15_5_10.BAK'
WITH FILE = 1, NOUNLOAD, STATS = 10
I get the following errors
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "E:\DATABASES\MPRM.mdf" failed with the operating system error 2(The system cannot find the file specified.).
Msg 3156, Level 16, State 3, Line 1
File 'MPRM' cannot be restored to 'E:\DATABASES\MPRM.mdf'. Use WITH MOVE to identify a valid location for the file.
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "E:\DATABASES\MPRM_log.ldf" failed with the operating system error 2(The system cannot find the file specified.).
Msg 3156, Level 16, State 3, Line 1
File 'MPRM_log' cannot be restored to 'E:\DATABASES\MPRM_log.ldf'. Use WITH MOVE to identify a valid location for the file.
Msg 3119, Level 16, State 1, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
Why the system asks about *.mdf, *.ldf files ? Is it anything related with Backup option rather than Restore script ?
I logged in with Windows Authentication
You need to specify where to store the physical files when you restore a .bak if your target server doesn't have the same disk/directory layout as the original source server. The backup file contains the logical SQL Server files along with the original location on the source server (the full physical path where the .mdf and .ldf where located).
So you need to use something like this:
RESTORE DATABASE [MPRM]
FROM DISK = N'\\rauf\shared\MPRM_15_5_10.BAK'
WITH FILE = 1,
MOVE N'MPRM' TO N'D:\MSSQL\Data\MPRM.mdf',
MOVE N'MPRM_Log' TO N'D:\MSSQL\Data\MPRM_Log.ldf',
NOUNLOAD, REPLACE,
STATS = 10
This command here:
MOVE N'MPRM' TO N'D:\MSSQL\Data\MPRM.mdf',
specifies that the logical file called MPRM (that's the default when you didn't specify anything else when creating your SQL Server database) should be moved during restore to the physical location D:\MSSQL\Data\MPRM.mdf (adapt this as needed)
To just see what is contained inside a backup file, you can use this command here:
RESTORE FILELISTONLY
FROM DISK = N'\\rauf\shared\MPRM_15_5_10.BAK'
This will show you all the logical files inside your backup, along with their original physical file that they were backed up from (on the source server, where you ran the backup command).