how to know which database is corrupted

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

how to know which database is corrupted

J Decker
I have a database that got corrupted; was working on implementing automatic
recovery....

I have a callback configured on SQLITE_CONFIG_LOG
sqlite3_config( SQLITE_CONFIG_LOG, errorLogCallback, 0);

Which is global, and does not identify the instance.  I figured, I could
just easily register the same callback on the db connection object....

sqlite3_db_config( odbc->db, SQLITE_CONFIG_LOG, dbErrorLogCallback, odbc );

But that's not supported per connection.
So how do I know which connection is executing a statement that failed?  (I
could potentially have more than one query active at the same time in
different databases)

Also; should I post that error as an async error?  I mean... in the
callback for the log, a query is outstanding on a statement in the db; so I
suppose I should let that unwind before doing further operations....
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to know which database is corrupted

Richard Hipp-3
On 7/24/18, J Decker <[hidden email]> wrote:

>
> I have a callback configured on SQLITE_CONFIG_LOG
> sqlite3_config( SQLITE_CONFIG_LOG, errorLogCallback, 0);
>
> Which is global, and does not identify the instance.  I figured, I could
> just easily register the same callback on the db connection object....
>
> sqlite3_db_config( odbc->db, SQLITE_CONFIG_LOG, dbErrorLogCallback, odbc );
>
> But that's not supported per connection.
> So how do I know which connection is executing a statement that failed?

There is no way to do that.  The reason is that these errors are often
dispatched from way down inside the I/O routines which have no
knowledge of which database connection they are servicing.

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to know which database is corrupted

Simon Slavin-3
In reply to this post by J Decker
On 24 Jul 2018, at 8:43pm, J Decker <[hidden email]> wrote:

> I have a database that got corrupted; was working on implementing automatic
> recovery....

It would be a million times better to figure out how the corruption occurs and prevent it.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to know which database is corrupted

J Decker
On Tue, Jul 24, 2018 at 1:47 PM Simon Slavin <[hidden email]> wrote:

> On 24 Jul 2018, at 8:43pm, J Decker <[hidden email]> wrote:
>
> > I have a database that got corrupted; was working on implementing
> automatic
> > recovery....
>
> It would be a million times better to figure out how the corruption occurs
> and prevent it.
>

Well...I've been considering that.   that database is written to when the
window moves (so I restore the position); and during startup.  It's just a
database for program options, which are loaded at the start, created if
they don't exist, given defaults, and can be updated during startup with a
script that gets loaded.

If the system rebooted; did a screen size change, and terminated the
program, it's possible it coild cause corruption.

On tree page 41 cell 37: Rowid 45783 out of order
... 37 to 0
On tree page 41 cell 0: Rowid 45787 out of order
On tree page 6 cell 166: Rowid 45787 out of order
On tree page 42 cell 40: Rowid 45787 out of order
... 40-0
On tree page 42 cell 0: Rowid 45787 out of order
On tree page 6 cell 165: Rowid 45787 out





>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to know which database is corrupted

Simon Slavin-3
On 24 Jul 2018, at 11:34pm, J Decker <[hidden email]> wrote:

> If the system rebooted; did a screen size change, and terminated the
> program, it's possible it coild cause corruption.

Step 1: use the command-line tool to fix your existing corruption.

Step 2: prevent more corruption.

Ignoring the possibbility of bad programming (overwriting SQLite's memory or files) my guess is that your corruption is caused by not closing the database properly before the computer reboots.

Could you close the database if no changes are made to it for one minute ? Reopen it when it's needed again.  Seems like a lot of window position changes would be done for a short time, then no more for a long time.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to know which database is corrupted

J Decker
On Tue, Jul 24, 2018 at 5:11 PM Simon Slavin <[hidden email]> wrote:

> On 24 Jul 2018, at 11:34pm, J Decker <[hidden email]> wrote:
>
> > If the system rebooted; did a screen size change, and terminated the
> > program, it's possible it coild cause corruption.
>
> Step 1: use the command-line tool to fix your existing corruption.
>
I don't have the vfs driver as a sqlite3 loadable module; if I did, I don't
know the keys.... I could know but that's a lot of work.

It could have hapepened because the program was at a breakpoint when the
system ended.

>
> Step 2: prevent more corruption.
>
ya; turns out it'll be a bunch of code that never runs...

Quick question though - do I hae to attempt to keep afinity for values in
an insert?

Insert into * values ( '1234', 'asdf', "0.3422" );
/* where * is a list built from querying select * fields */
Other than haveing to escape anything with ' in it?  (or \0 )



>
> Ignoring the possibbility of bad programming (overwriting SQLite's memory
> or files) my guess is that your corruption is caused by not closing the
> database properly before the computer reboots.
>
> Could you close the database if no changes are made to it for one minute ?
> Reopen it when it's needed again.  Seems like a lot of window position
> changes would be done for a short time, then no more for a long time.
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users