Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 06:41 AM
BluDes
 
Posts: n/a
Default PostgreSQL Data Loss

Hi everyone,
I have a problem with one of my costomers.
I made a program that uses a PostgreSQL (win32) database to save its data.
My customer claims that he lost lots of data reguarding his own clients
and that those data had surely been saved on the database.
My first guess is that he is the one who deleted the data but wants to
blame someone else, obviously I can't prove it.

Could it be possible for PostgreSQL to lose its data? Maybe with a file
corruption? Could it be possible to restore these data?

My program does not modify or delete data since its more like a log that
only adds information. It is obviously possible to delete these logs but
it requires to answer "yes" to 2 different warnings, so the data can't
be deleted accidentally.

I have other customers with even 10 times the amount of data of the one
who claimed the loss but no problems with them.
He obviously made no backups (and claims whe never told him to do them
so we are responsible even for this) though the program has a dedicated
Backup-section.

Any suggestion?

Daniele
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 06:43 AM
Heikki Linnakangas
 
Posts: n/a
Default Re: PostgreSQL Data Loss

BluDes wrote:
> I made a program that uses a PostgreSQL (win32) database to save its data.


What version of PostgreSQL is this?

> My customer claims that he lost lots of data reguarding his own clients
> and that those data had surely been saved on the database.
> My first guess is that he is the one who deleted the data but wants to
> blame someone else, obviously I can't prove it.


Did he lose all data in one table, or just some rows? Or is there some
other pattern?

> Could it be possible for PostgreSQL to lose its data?


Not when properly installed.

> Maybe with a file corruption?


I doubt it. You'd almost certainly get warnings or errors if there's
corruption.

> Could it be possible to restore these data?


The first thing to do is to take a filesystem-level physical copy of the
data directory to prevent further damage. Copy the data directory to
another system for forensics.

You might be able to get a picture of what happened by looking at the
WAL logs using the xlogviewer tool in pgfoundry.

You can also modify the PostgreSQL source code so that it shows also row
versions marked as deleted, and recover the deleted data. I can't
remember exactly how to do it, maybe others who have done it can fill
in. A row stays physically in the file until the table is vacuumed;
hopefully it hasn't been.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 06:43 AM
Zdenek Kotala
 
Posts: n/a
Default Re: PostgreSQL Data Loss

If data are deleted then they are still stored in database until VACUUM
cleans them. You can look by some hex viewer, if you see some know text
data there. Or I think there is also some tool which dump tuple list
from pages.

You can also see deleted data if you change current transaction ID. But
I not sure if it is simply possible.

Before experiments, do not forget backup of database files.

Zdenek

BluDes wrote:
> Hi everyone,
> I have a problem with one of my costomers.
> I made a program that uses a PostgreSQL (win32) database to save its data.
> My customer claims that he lost lots of data reguarding his own clients
> and that those data had surely been saved on the database.
> My first guess is that he is the one who deleted the data but wants to
> blame someone else, obviously I can't prove it.
>
> Could it be possible for PostgreSQL to lose its data? Maybe with a file
> corruption? Could it be possible to restore these data?
>
> My program does not modify or delete data since its more like a log that
> only adds information. It is obviously possible to delete these logs but
> it requires to answer "yes" to 2 different warnings, so the data can't
> be deleted accidentally.
>
> I have other customers with even 10 times the amount of data of the one
> who claimed the loss but no problems with them.
> He obviously made no backups (and claims whe never told him to do them
> so we are responsible even for this) though the program has a dedicated
> Backup-section.
>
> Any suggestion?
>
> Daniele
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings



---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 06:43 AM
J. Andrew Rogers
 
Posts: n/a
Default Re: PostgreSQL Data Loss


On Jan 26, 2007, at 2:22 AM, BluDes wrote:
> I have a problem with one of my costomers.
> I made a program that uses a PostgreSQL (win32) database to save
> its data.
> My customer claims that he lost lots of data reguarding his own
> clients and that those data had surely been saved on the database.
> My first guess is that he is the one who deleted the data but wants
> to blame someone else, obviously I can't prove it.
>
> Could it be possible for PostgreSQL to lose its data? Maybe with a
> file corruption? Could it be possible to restore these data?
>
> My program does not modify or delete data since its more like a log
> that only adds information. It is obviously possible to delete
> these logs but it requires to answer "yes" to 2 different warnings,
> so the data can't be deleted accidentally.
>
> I have other customers with even 10 times the amount of data of the
> one who claimed the loss but no problems with them.
> He obviously made no backups (and claims whe never told him to do
> them so we are responsible even for this) though the program has a
> dedicated Backup-section.



I have seen this data loss pattern many, many times, and on Oracle
too. The most frequent culprits in my experience:

1.) The customer screwed up big time and does not want to admit that
they made a mistake, hoping you can somehow pull their butt out of
the fire for free.

2.) Someone else sabotaged or messed up the customers database, and
the customer is not aware of it.

3.) The customer deleted their own data and is oblivious to the fact
that they are responsible.

4.) There is some rare edge case in your application that generates
SQL that deletes all the data.


There is always the possibility that there is in fact some data loss
due to a failure of the database, but it is a rare kind of corruption
that deletes a person's data but leaves everything else intact with
no error messages, warnings, or other indications that something is
not right. Given the description of the problem, I find an internal
failure of the database to be a low probability reason for the data
loss.


Having run many database systems that had various levels of pervasive
internal change auditing/versioning, often unbeknownst to the casual
user, virtually all of the several "data loss" cases I've seen with a
description like the above clearly fit in the cases #1-3 above when
we went into the audit logs i.e. someone explicitly did the
deleting. I cannot tell you how many times people have tried to
pretend that the database "lost" or "messed up" their data and then
been embarrassed when they discover that I can step through every
single action they took to destroy their own data. I've never seen a
single case like the one described above that was due to an internal
database failure; when there is an internal database failure, it is
usually ugly and obvious.

Cheers,

J. Andrew Rogers
jrogers@neopolitan.com




---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-12-2008, 06:43 AM
Andrew Dunstan
 
Posts: n/a
Default Re: PostgreSQL Data Loss

BluDes wrote:
> Hi everyone,
> I have a problem with one of my costomers.
> I made a program that uses a PostgreSQL (win32) database to save its
> data.
> My customer claims that he lost lots of data reguarding his own
> clients and that those data had surely been saved on the database.
> My first guess is that he is the one who deleted the data but wants to
> blame someone else, obviously I can't prove it.
>
> Could it be possible for PostgreSQL to lose its data? Maybe with a
> file corruption? Could it be possible to restore these data?
>
> My program does not modify or delete data since its more like a log
> that only adds information. It is obviously possible to delete these
> logs but it requires to answer "yes" to 2 different warnings, so the
> data can't be deleted accidentally.
>
> I have other customers with even 10 times the amount of data of the
> one who claimed the loss but no problems with them.
> He obviously made no backups (and claims whe never told him to do them
> so we are responsible even for this) though the program has a
> dedicated Backup-section.
>
> Any suggestion?
>
>


This isn't any sort of report that can be responded to. We need to know
what has happened to the machine, what is in the server logs, what are
the symptoms of data loss. The most likely explanations are pilot error
and hardware error.

cheers

andrew


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-12-2008, 06:43 AM
Gregory Stark
 
Posts: n/a
Default Re: PostgreSQL Data Loss

"BluDes" <DESPAMMAMIdarocchi@PERFAVOREtiscali.it> writes:

> My customer claims that he lost lots of data reguarding his own clients and
> that those data had surely been saved on the database.


Has this Postgres database been running for a long time? There is a regular
job called VACUUM that has to be run on every table periodically to recover
free space.

If this isn't run for a very long time (how long depends on how busy the
database is, but even on extremely large databases it's usually a matter of
months, on more normal databases it would be years) then very old records seem
to suddenly disappear. There is a way to recover data that this has happened
to though as long as you don't run vacuum after the data has disappeared.

To repeat: If you think this may have happened DO NOT run vacuum now.

Do you think this may have happened? How long ago was this database created?
Does your system periodically run VACUUM? Is the missing data in every table
or just a particular table?

Incidentally recent versions of Postgres don't allow this to occur and stop
running with a message insisting you run vacuum before continuing.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-12-2008, 06:44 AM
Martijn van Oosterhout
 
Posts: n/a
Default Re: PostgreSQL Data Loss

On Sat, Jan 27, 2007 at 12:11:59AM +0000, Gregory Stark wrote:
> If this isn't run for a very long time (how long depends on how busy the
> database is, but even on extremely large databases it's usually a matter of
> months, on more normal databases it would be years) then very old recordsseem
> to suddenly disappear. There is a way to recover data that this has happened
> to though as long as you don't run vacuum after the data has disappeared.
>
> To repeat: If you think this may have happened DO NOT run vacuum now.


Actually, for XID wraparound a VACUUM may actually be the right thing.
I looked at this (with guidence from Tom) and we came to the conclusion
that XID wraparound will hide tuples older than 2 billion transaction,
but VACUUM will mark as frozen anything newer than 3 billion
transactions, so for 1 billion transactions you can actually get your
data back.

Expect for things like uniqueness guarentees, but they're solvable.

Not that I'm saying that the OP has this issue...

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFuuOVIB7bNG8LQkwRAvnTAJ9AvtDRdQ1fvrvW/wfzArM85qevDgCgi3zD
+ajWmWcc0J6tA45e9iayrUM=
=T5wz
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-12-2008, 06:44 AM
desrocchi@gmail.com
 
Posts: n/a
Default Re: PostgreSQL Data Loss



On 27 Gen, 06:31, klep...@svana.org (Martijn van Oosterhout) wrote:

> > To repeat: If you think this may have happened DO NOT run vacuum now.Actually, for XID wraparound a VACUUM may actually be the right thing.

> I looked at this (with guidence from Tom) and we came to the conclusion
> that XID wraparound will hide tuples older than 2 billion transaction,
> but VACUUM will mark as frozen anything newer than 3 billion
> transactions, so for 1 billion transactions you can actually get your
> data back.
>
> Expect for things like uniqueness guarentees, but they're solvable.


Hello,
thank you all for the help.
@Andrew Dunstan: this is the first time I'm having this kind of
problem with PostgreSQL, I'm sorry I didn't provide all the needed
information.
Let me try to fill in something:
- the postgresql version is 8.1.4-1
- as far as I know, nothing happened to the machine. I work near
Milan, my customer is from something between Rome and Tuscany. It
would be a long jurney to retrieve a PC that he surely won't give us.
- The server logs... huh? Never heard of them... or better, never
needed. Where can I find them?

There is even a more foolish explanation to all of this, but my
customer denied this happened:
in my program it is possible to deactivate the auto-save function of
the work done. Without this option the user has to click himself the
button to store the data on the database... so it could even be that
I'm trying to find data that has never even been saved.

Anyway this teaches me that I have to put logs in my programs to trace
every single time the users change settings.

Bye,
Daniele

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:00 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723