Unix Technical Forum

SEO

vBulletin Search Engine Optimization


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

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 08:35 PM
Michael Monnerie
 
Posts: n/a
Default duplicate primary index in bayes db from SpamAssassin

Dear list, I don't know whether pgsql-admin or the SA list is the
correct one to ask, so I start here. I have a bayes Postgres database
for SpamAssassin, which I use shared from 2 servers to have the same
content. I think this could be a locking issue or whatever, I don't
care. BUT: I have lots of "duplicate index" elements now, preventing a
restore or cleanup. Here's the dump and diff if anyone cares:
http://zmi.at/x/bayes_dup_idx.dump.bz2 (upload currently running)
http://zmi.at/x/bayes_dup_idx.diff.bz2

Could the problem be caused by any settings to the DB, or because of the
stored procedures? Normally there should be no way this can happen, so
what can cause this?

mfg zmi
--
// Michael Monnerie, Ing.BSc ----- http://it-management.at
// Tel: 0676/846 914 666 .network.your.ideas.
// PGP Key: "curl -s http://zmi.at/zmi.asc | gpg --import"
// Fingerprint: AC19 F9D5 36ED CD8A EF38 500E CE14 91F7 1C12 09B4
// Keyserver: www.keyserver.net Key-ID: 1C1209B4

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)

iD8DBQBIA37hzhSR9xwSCbQRAosAAJ9ssydP1DfhJf5JcYtnN2 PLVVcA9gCfTpbU
t0WewrClcT7p/3jq/8wBXsk=
=ghrp
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 08:35 PM
Tom Lane
 
Posts: n/a
Default Re: duplicate primary index in bayes db from SpamAssassin

Michael Monnerie <michael.monnerie@it-management.at> writes:
> care. BUT: I have lots of "duplicate index" elements now, preventing a
> restore or cleanup.


What PG version is this?

regards, tom lane

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 08:35 PM
Alvaro Herrera
 
Posts: n/a
Default Re: duplicate primary index in bayes db from SpamAssassin

Michael Monnerie wrote:
> Dear list, I don't know whether pgsql-admin or the SA list is the
> correct one to ask, so I start here. I have a bayes Postgres database
> for SpamAssassin, which I use shared from 2 servers to have the same
> content. I think this could be a locking issue or whatever, I don't
> care.


What do you mean "shared from 2 servers"? Are these two servers using a
shared network mount with the database files? Or do you mean that these
two servers connect as clients to a single Postgres server?

What versions of things are all these running? Please be as specific as
humanly possible.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-15-2008, 08:35 PM
Michael Monnerie
 
Posts: n/a
Default Re: duplicate primary index in bayes db from SpamAssassin

On Montag, 14. April 2008 Tom Lane wrote:
> What PG version is this?


Sorry:
# select version();
version
------------------------------------------------------------------------------------------------------------
PostgreSQL 8.1.11 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2
20061115 (prerelease) (SUSE Linux)

It's the RPM installed from openSUSE 10.2

mfg zmi
--
// Michael Monnerie, Ing.BSc ----- http://it-management.at
// Tel: 0676/846 914 666 .network.your.ideas.
// PGP Key: "curl -s http://zmi.at/zmi.asc | gpg --import"
// Fingerprint: AC19 F9D5 36ED CD8A EF38 500E CE14 91F7 1C12 09B4
// Keyserver: www.keyserver.net Key-ID: 1C1209B4

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)

iD8DBQBIA7EQzhSR9xwSCbQRAlcRAKCQfhrQAqiR0PNvd0ecLh eq26Y6KACgzEll
+x7UX5y2iXtIuhQh5pPhXbs=
=Iliu
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-15-2008, 08:35 PM
Michael Monnerie
 
Posts: n/a
Default Re: duplicate primary index in bayes db from SpamAssassin

On Montag, 14. April 2008 Alvaro Herrera wrote:
> What do you mean "shared from 2 servers"? *Are these two servers
> using a shared network mount with the database files? *Or do you mean
> that these two servers connect as clients to a single Postgres
> server?


Two servers have SA running, and connect via different users (who have
the same access rights) to the same Postgres server running the bayes
db.

> What versions of things are all these running? *Please be as specific
> as humanly possible.


# select version();
version
------------------------------------------------------------------------------------------------------------
PostgreSQL 8.1.11 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2
20061115 (prerelease) (SUSE Linux)

It's the RPM installed from openSUSE 10.2

The SA versions are 3.2.0 from one server and 3.2.4 from the other.

mfg zmi
--
// Michael Monnerie, Ing.BSc ----- http://it-management.at
// Tel: 0676/846 914 666 .network.your.ideas.
// PGP Key: "curl -s http://zmi.at/zmi.asc | gpg --import"
// Fingerprint: AC19 F9D5 36ED CD8A EF38 500E CE14 91F7 1C12 09B4
// Keyserver: www.keyserver.net Key-ID: 1C1209B4

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)

iD8DBQBIA7pDzhSR9xwSCbQRAtxNAJsHv6ht9aOeSXgrn6T5Bz F845TErwCfXSYz
vn2+7IV9jnBMU17PEV6Oa4s=
=DXN/
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-17-2008, 04:10 PM
Michael Monnerie
 
Posts: n/a
Default Re: duplicate primary index in bayes db from SpamAssassin

On Montag, 14. April 2008 Tom Lane wrote:
> What PG version is this?


I've looked a little more into history, and PostgreSQL was 8.1.5
originally from CD, then 8.1.9 and now 8.1.11.

I'm currently investigating a way to delete duplicates from the table.
Is there any chance to do that? A
SELECT * from bayes_token;
shows no dups, as there's a primary index... at least it works here.

This is the bayes_token table and its index:
CREATE TABLE bayes_token (
id integer DEFAULT 0 NOT NULL,
token bytea DEFAULT ''::bytea NOT NULL,
spam_count integer DEFAULT 0 NOT NULL,
ham_count integer DEFAULT 0 NOT NULL,
atime integer DEFAULT 0 NOT NULL
);
ALTER TABLE ONLY bayes_token
ADD CONSTRAINT bayes_token_pkey PRIMARY KEY (id, token);

Could I create a new db without indices, restore the data there, and
then run a "delete from.. where duplicates"? Sometimes there's 3x the
same content in the primary index, but I'd need to delete all except
the one with the highest spam_count.

I just found I even have a duplicate in bayes_vars:

COPY bayes_vars (id, username, spam_count, ham_count, token_count,
last_expire, last_atime_delta, last_expire_reduce, oldest_token_age,
newest_token_age) FROM stdin;
1 vscan 194393 517531 2602114 1206030039 2764800 15304
1203265204 1206057801
1 vscan 194398 517535 2602799 1206030039 2764800 15304
1203265204 1206064729
4 vscan 18305 25403 2042983 1208143427 1382400 13268
1206501543 1208216540
\.

Definition:
CREATE TABLE bayes_vars (
id serial NOT NULL,
username character varying(200) DEFAULT ''::character varying NOT
NULL,
spam_count integer DEFAULT 0 NOT NULL,
ham_count integer DEFAULT 0 NOT NULL,
token_count integer DEFAULT 0 NOT NULL,
last_expire integer DEFAULT 0 NOT NULL,
last_atime_delta integer DEFAULT 0 NOT NULL,
last_expire_reduce integer DEFAULT 0 NOT NULL,
oldest_token_age integer DEFAULT 2147483647 NOT NULL,
newest_token_age integer DEFAULT 0 NOT NULL
);
ALTER TABLE ONLY bayes_vars
ADD CONSTRAINT bayes_vars_pkey PRIMARY KEY (id);

But here, I could see the dups with SELECT, and even delete one record:

# select * from bayes_vars;
id | username | spam_count | ham_count | token_count | last_expire |
last_atime_delta | last_expire_reduce | oldest_token_age |
newest_token_age
----+----------+------------+-----------+-------------+-------------+------------------+--------------------+------------------+------------------
1 | vscan | 194393 | 517531 | 2602114 | 1206030039 |
2764800 | 15304 | 1203265204 | 1206057801
1 | vscan | 194398 | 517535 | 2602799 | 1206030039 |
2764800 | 15304 | 1203265204 | 1206064729
4 | vscan | 18375 | 25828 | 2050196 | 1208229525 |
1382400 | 13268 | 1206501543 | 1208240610
(3 Zeilen)

bayes_pg_v1=# delete from bayes_vars where spam_count =194393;
DELETE 1
bayes_pg_v1=# select * from bayes_vars;
id | username | spam_count | ham_count | token_count | last_expire |
last_atime_delta | last_expire_reduce | oldest_token_age |
newest_token_age
----+----------+------------+-----------+-------------+-------------+------------------+--------------------+------------------+------------------
1 | vscan | 194398 | 517535 | 2602799 | 1206030039 |
2764800 | 15304 | 1203265204 | 1206064729
4 | vscan | 18375 | 25829 | 2050215 | 1208229525 |
1382400 | 13268 | 1206501543 | 1208240637
(2 Zeilen)

mfg zmi
--
// Michael Monnerie, Ing.BSc ----- http://it-management.at
// Tel: 0676/846 914 666 .network.your.ideas.
// PGP Key: "curl -s http://zmi.at/zmi.asc | gpg --import"
// Fingerprint: AC19 F9D5 36ED CD8A EF38 500E CE14 91F7 1C12 09B4
// Keyserver: www.keyserver.net Key-ID: 1C1209B4

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)

iD8DBQBIBEqdzhSR9xwSCbQRAsfeAJ4y1ElbYuiIy5e6VWJK55 +VBLl2+QCfb6CB
gXGPhHm6GpycgFubsT2I+hQ=
=Hi+r
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-17-2008, 04:10 PM
Michael Monnerie
 
Posts: n/a
Default Re: duplicate primary index in bayes db from SpamAssassin

On Montag, 14. April 2008 Michael Monnerie wrote:
> > What do you mean "shared from 2 servers"? *Are these two servers
> > using a shared network mount with the database files? *Or do you
> > mean that these two servers connect as clients to a single Postgres
> > server?

>
> Two servers have SA running, and connect via different users (who
> have the same access rights) to the same Postgres server running the
> bayes db.


SA=SpamAssassin, I should possibly explain. There are stored procedures
in the DB which get called, could the problem be connected to this?

mfg zmi
--
// Michael Monnerie, Ing.BSc ----- http://it-management.at
// Tel: 0676/846 914 666 .network.your.ideas.
// PGP Key: "curl -s http://zmi.at/zmi.asc | gpg --import"
// Fingerprint: AC19 F9D5 36ED CD8A EF38 500E CE14 91F7 1C12 09B4
// Keyserver: www.keyserver.net Key-ID: 1C1209B4

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)

iD8DBQBIBPOizhSR9xwSCbQRAsXRAKC+zezt02RkqSxDjF3Uaw PhT69Z5wCfUTpT
3+xhXPOQQ3P51zLLbsOhGU0=
=bcYt
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-17-2008, 04:10 PM
Michael Monnerie
 
Posts: n/a
Default Re: duplicate primary index in bayes db from SpamAssassin

On Montag, 14. April 2008 Michael Monnerie wrote:
> problem with duplicate primary index entries...


I just got a warning in my Log:

Apr 16 01:52:19 db1.zmi.at postgres[21103]: [3-1] DB=bayes_pg_v1_dupidx
U=postgres H=[local] 48053eaf.526f VACUUM:WARNUNG:
Index »bayes_token_pkey« enthält 2539650 Zeilenversionen, aber Tabelle
enthält 4752337 Zeilenversionen
(Index contains 2539650 rows, but table has 4752337 rows)

BTW: I know that the DB language cannot be changed without recreating,
but can I change the language of the log messages?

mfg zmi
--
// Michael Monnerie, Ing.BSc ----- http://it-management.at
// Tel: 0676/846 914 666 .network.your.ideas.
// PGP Key: "curl -s http://zmi.at/zmi.asc | gpg --import"
// Fingerprint: AC19 F9D5 36ED CD8A EF38 500E CE14 91F7 1C12 09B4
// Keyserver: www.keyserver.net Key-ID: 1C1209B4

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)

iD4DBQBIBUC7zhSR9xwSCbQRAmeZAJi4r/Jd8rkLbckWDKN8G/2InCp4AJ41tS8q
x1VJKM4yeyxdTQ5pL9jJ6Q==
=OkBh
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-17-2008, 04:10 PM
Michael Monnerie
 
Posts: n/a
Default Re: duplicate primary index in bayes db from SpamAssassin

On Mittwoch, 16. April 2008 Michael Monnerie wrote:
> problem with duplicate primary index entries...


I created the bayes db fresh, named it bayes_pg_v2 and re-relearned all
ham/spam from 3 concurrent connections into the db. No problem so far.

But I renamed the old, broken db and tried a
and got this:
INFO: »bayes_token«: 20567514 entfernbare, 4752337 nicht entfernbare
Zeilenversionen in 186274 Seiten gefunden
DETAIL: 0 tote Zeilenversionen können noch nicht entfernt werden.
Nicht entfernbare Zeilenversionen sind zwischen 56 und 56 Bytes lang.
Es gibt 0 unbenutzte Itemzeiger.
Gesamter freier Platz (einschließlich entfernbare Zeilenversionen) ist
1154820852 Bytes.
33480 Seiten sind leer oder werden leer werden, einschließlich 0 am Ende
der Tabelle.
186149 Seiten mit 1154819352 freien Bytes sind mögliche Ziele zum
Verschieben.

It looks like autovacuum - which is on - could not be run, and the db
growed a lot, and now a VACUUM cannot finish because of the duplicate
index:
INFO: Index »bayes_token_pkey« enthält 2539650 Zeilenversionen in 76273
Seiten
DETAIL: 0 Indexzeilenversionen wurde entfernt.
11727 Indexseiten wurden gelöscht, 11727 sind gegenwärtig
wiederverwendbar.
CPU 10.44s/2.49u sec elapsed 172.59 sec.
WARNUNG: Index »bayes_token_pkey« enthält 2539650 Zeilenversionen, aber
Tabelle enthält 4752337 Zeilenversionen
TIP: Bauen Sie den Index mit REINDEX neu.

But REINDEX doesn't work of course, because of the duplicates...

I'd like to drop that broken db, or should I keep it for analyzation?

mfg zmi
--
// Michael Monnerie, Ing.BSc ----- http://it-management.at
// Tel: 0676/846 914 666 .network.your.ideas.
// PGP Key: "curl -s http://zmi.at/zmi.asc | gpg --import"
// Fingerprint: AC19 F9D5 36ED CD8A EF38 500E CE14 91F7 1C12 09B4
// Keyserver: www.keyserver.net Key-ID: 1C1209B4

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)

iD8DBQBIBwAvzhSR9xwSCbQRAq4uAKCSqqoN/HP0URn5CUeMHaqGqu8OJACgtvxU
QkHAepyFbTa3K31HbPxrIBs=
=4Jcp
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-17-2008, 04:10 PM
Tom Lane
 
Posts: n/a
Default Re: duplicate primary index in bayes db from SpamAssassin

Michael Monnerie <michael.monnerie@it-management.at> writes:
> I'd like to drop that broken db, or should I keep it for analyzation?


Looking back over the thread, it seems that the problems you saw could
be explained by the VACUUM-related bugs we fixed in 8.1.9 and 8.1.10;
although obviously this theory requires assuming that the dups were
there before you updated to 8.1.11. You didn't say much about time
frame so I don't know if that's plausible.

This latest bit with many fewer index entries than table entries is just
weird, though. The 8.1.10 VACUUM bug could have led to having *more*
index entries than table entries, but not the other way around.

Before you zap the database, would you be willing to make the actual
database files (not a dump, but the stored files) available? I'd
be interested to take a closer look at that index.

regards, tom lane

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

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



All times are GMT. The time now is 12:42 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0

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