Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #21 (permalink)  
Old 04-19-2008, 06:27 AM
Greg Smith
 
Posts: n/a
Default Re: Expose checkpoint start/finish times into SQL.

On Thu, 3 Apr 2008, Joshua D. Drake wrote:

> For knowing how long checkpoints are taking. If they are taking too
> long you may need to adjust your bgwriter settings, and it is a
> serious drag to parse postgresql logs for this info.


There's some disconnect here between what I think you want here and what
Theo's patch does.

If I were running an 8.2 system, there's a whole lot of diagnostic
information I'd like to have handy in order to optimize checkpoints, as
you describe. But this patch doesn't help 8.2 users, because the whole
pg_stat_bgwriter structure is 8.3 only--it provides much of what is needed
in this area.

In 8.3, there is very little background writer tuning to do. What tuning
you can do is easy to figure out from what's in pg_stat_bgwriter. The new
checkpoint_completion_target feature works better than tuning the 8.2
background writer to reduce checkpoint spikes ever did anyway, and that's
the main thing that drives how long checkpoints take to process now.

So in the only situation where this patch can be applied, 8.3, I don't
think the scenario you describe is likely to pop up. And the combination
of two 8.3 features (log_checkpoint and the CSV logs, it's no coincidence
I worked on both) should allow a good enough way to hack around this area
when it does. Just make the logs rotate fairly regularly, and every time
they do import the last CSV section that's now finished into a table so
you can compute statistics about how the checkpoints are doing there. I
don't see why that sort of stuff should go into core when it's now easy to
do outside of it. I have a whole stack of scripts in that area I plan to
release over the summer.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #22 (permalink)  
Old 04-19-2008, 06:27 AM
Greg Smith
 
Posts: n/a
Default Re: Expose checkpoint start/finish times into SQL.

On Thu, 3 Apr 2008, Tom Lane wrote:

> As of PG 8.3, the bgwriter tries very hard to make the elapsed time of a
> checkpoint be just about checkpoint_timeout *
> checkpoint_completion_target, regardless of load factors.


In the cases where the timing on checkpoint writes are timeout driven.
When they're checkpoint_segments driven the time is derived from that
drumbeat instead. And those cases are the more interesting ones, because
those are the ones that will speed up during really busy periods.

I think it's completely relevant to track how often checkpoints are
happening because they do still vary even in 8.3. I'm just not sure if
the current methods available for that really aren't good enough, or if
it's just the case that not everyone is aware of all of them.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #23 (permalink)  
Old 04-19-2008, 06:27 AM
Robert Treat
 
Posts: n/a
Default Re: Expose checkpoint start/finish times into SQL.

On Friday 04 April 2008 00:09, Greg Smith wrote:
> On Thu, 3 Apr 2008, Robert Treat wrote:
> > You can plug a single item graphed over time into things like rrdtool to
> > get good trending information. And it's often easier to do this using
> > sql interfaces to get the data than pulling it out of log files (almost
> > like the db was designed for that :-)

>
> The pg_stat_bgwriter value for buffers_checkpoint was intentionally
> implemented in 8.3 such that it jumps in one big lump when the checkpoint
> is done. While it's not the ideal interface for what you're looking for,
> the reason for that is to made it possible to build a "when was the last
> checkpoint finished?" interface via some remote monitoring tool just by
> determining the last time that the value jumped upwards. You can easily
> see them just by graphing that value, it shouldn't be too hard to teach
> something with rrdtool guts to find them.
>


the advantage of using a timestamp is that you get the incrementing counter
for free which is certainly helpful in third party tools like phppgadmin that
don't instrument tracking methods; you can look at the system and it's
settings and have a pretty good idea if something is awry.

>
> Ultimately a lot of the other questions you might ask (i.e. "how many
> buffers have been written per hour by checkpoints?") require processing
> the numbers in this way anyway, and I thought this implementation was good
> enough to monitor the situation you're trying to avoid--presuming you're
> using some sort of moderately powerful remote monitoring tool. Theo's
> patch would make it easier to answer with a simple command which has some
> value; a little SQL in a cron job would be good enough to trigger an alert
> rather than needing a real monitoring probe.
>


Yes, the idea of making a basic nagios/munin check that is readily consumable
by the general public is certainly a bonus in my eyes.

I have to add, given that we already provide the time of last checkpoint
information via pg_controldata, I don't understand why people are against
making that information accesible to remote clients.

--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #24 (permalink)  
Old 04-19-2008, 06:27 AM
Tom Lane
 
Posts: n/a
Default Re: Expose checkpoint start/finish times into SQL.

Robert Treat <xzilla@users.sourceforge.net> writes:
> I have to add, given that we already provide the time of last checkpoint
> information via pg_controldata, I don't understand why people are against
> making that information accesible to remote clients.


So, I can expect to see a patch next week that invents a separate SQL
function to expose each field printed by pg_controldata?

You are failing to make the distinction between debug/developer support
(which is what pg_controldata is) and things that are interesting for
DBAs to track. Would you expect someone to install handwritten
monitoring infrastructure to awaken them in the middle of the night when
pg_control_version changes?

I am not saying that there is no use for some sort of facility in this
area. But I think it needs some more-general thinking and design than
has been evidenced so far in this thread.

regards, tom lane

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #25 (permalink)  
Old 04-19-2008, 06:27 AM
Tom Lane
 
Posts: n/a
Default Re: Expose checkpoint start/finish times into SQL.

Greg Smith <gsmith@gregsmith.com> writes:
> On Thu, 3 Apr 2008, Tom Lane wrote:
>> I'd much rather be spending our time and effort on understanding what
>> broke for you, and fixing the code so it doesn't happen again.


> [ shit happens... ]


Completely fair, but I still don't see how this particular patch would
be a useful addition to the DBA's monitoring-tool arsenal. The scope
seems too narrow.

(And you still didn't tell me what the actual failure case was.)

regards, tom lane

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #26 (permalink)  
Old 04-19-2008, 06:27 AM
Greg Smith
 
Posts: n/a
Default Re: Expose checkpoint start/finish times into SQL.

On Fri, 4 Apr 2008, Tom Lane wrote:

> (And you still didn't tell me what the actual failure case was.)


Database stops checkpointing. WAL files pile up. In the middle of
backup, system finally dies, and when it starts recovery there's a bad
record in the WAL files--which there are now thousands of to apply, and
the bad one is 4 hours of replay in. Believe it or not, it goes downhill
from there.

It's what kicked off the first step that's the big mystery. The only code
path I thought of that can block checkpoints like this is when the
archive_command isn't working anymore, and that wasn't being used. Given
some of the other corruption found later and the bad memory issues
discovered, a bit flipping in the "do I need to checkpoint now?" code or
data seems just as likely as any other explanation.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #27 (permalink)  
Old 04-19-2008, 06:27 AM
Tom Lane
 
Posts: n/a
Default Re: Expose checkpoint start/finish times into SQL.

Greg Smith <gsmith@gregsmith.com> writes:
> On Fri, 4 Apr 2008, Tom Lane wrote:
>> (And you still didn't tell me what the actual failure case was.)


> Database stops checkpointing. WAL files pile up. In the middle of
> backup, system finally dies, and when it starts recovery there's a bad
> record in the WAL files--which there are now thousands of to apply, and
> the bad one is 4 hours of replay in. Believe it or not, it goes downhill
> from there.


> It's what kicked off the first step that's the big mystery.


Indeed :-(. But given those observations, I'd still have about zero
faith in the usefulness of this patch. If the bgwriter is not able to
complete checkpoints, is it able to tell you the truth about what it's
doing?

The actual advice I'd give to a DBA faced with such a case is to
kill -ABRT the bgwriter and send the stack trace to -hackers.
That's not in the proposed patch though...

regards, tom lane

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #28 (permalink)  
Old 04-19-2008, 06:27 AM
Greg Smith
 
Posts: n/a
Default Re: Expose checkpoint start/finish times into SQL.

On Fri, 4 Apr 2008, Tom Lane wrote:

> The actual advice I'd give to a DBA faced with such a case is to
> kill -ABRT the bgwriter and send the stack trace to -hackers.


And that's a perfect example of where they're trying to get to. They
didn't notice the problem until after the crash. The server didn't come
back up (busy processing WALs) and that downtime was caught by a
monitoring system. At that point it was too late to collect debugging
information on what was wrong inside the server processes that might have
given a clue what happened.

If they'd have noticed it while the server was up, perhaps because the
"last checkpoint" value hadn't changed in a long time (which seems like it
might be available via stats even if, as you say, the background writer is
out of its mind at that point), they could have done such a kill and
collected some actual useful information here. That's the theory at
least.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #29 (permalink)  
Old 04-19-2008, 06:27 AM
Tom Lane
 
Posts: n/a
Default Re: Expose checkpoint start/finish times into SQL.

Greg Smith <gsmith@gregsmith.com> writes:
> ... If they'd have noticed it while the server was up, perhaps because the
> "last checkpoint" value hadn't changed in a long time (which seems like it
> might be available via stats even if, as you say, the background writer is
> out of its mind at that point), they could have done such a kill and
> collected some actual useful information here. That's the theory at
> least.


Well, mebbe, but that still seems to require a lot of custom monitoring
infrastructure that is not present in this patch, and furthermore that
this patch doesn't especially aid the development of.

regards, tom lane

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #30 (permalink)  
Old 04-19-2008, 06:27 AM
Gregory Stark
 
Posts: n/a
Default Re: Expose checkpoint start/finish times into SQL.

"Alvaro Herrera" <alvherre@commandprompt.com> writes:

> Tom Lane wrote:
>> Greg Smith <gsmith@gregsmith.com> writes:
>> > ... If they'd have noticed it while the server was up, perhaps because the
>> > "last checkpoint" value hadn't changed in a long time (which seems like it
>> > might be available via stats even if, as you say, the background writer is
>> > out of its mind at that point), they could have done such a kill and
>> > collected some actual useful information here. That's the theory at
>> > least.

>>
>> Well, mebbe, but that still seems to require a lot of custom monitoring
>> infrastructure that is not present in this patch, and furthermore that
>> this patch doesn't especially aid the development of.

>
> These kind of things can be monitored externally very easily, say by
> Nagios, when the values are available via the database. If you have to
> troll the logs, it's quite a bit harder to do it.


I can see Tom's reluctance out of fear that really this is going to be the
first of hundreds of dials which have to be monitored so a single function to
handle that single dial is kind of short sighted. I would think eventually it
should be part of the Postgres SNMP MIB.

But I would say from my experience on the not-really-a-sysadmin side I think
the time of the last checkpoint is probably the *most* important thing to be
monitoring. Effectively it's monitoring how stale your data on disk is
potentially becoming by showing how much recovery will be necessary.

> I'm not sure about the right values to export -- last checkpoint start
> time is the most obvious idea, but I would also suggest exporting last
> checkpoint end, or NULL if the checkpoint is ongoing; and also previous-
> to-last checkpoint start and end.


I'm surprised y'all want the time of the last checkpoint *start* though. It
seems to me that only the last checkpoint *end* is actually interesting. A
checkpoint which has started but not ended yet is not really a checkpoint at
all. It's nothing.

In the future there could be multiple checkpoints which have "started" but not
finished. Or we could add support for lazy checkpoints in which case there
could be an infinite number of "potential" checkpoints which haven't finished.

Worse, the time the last checkpoint actually finished isn't actually
interesting either. What you want to know is what time the record which the
last finished checkpoint *checkpointed up to* was inserted. That is, the time
of the record that the last checkpoint record *points to*.

That represents the "guarantee" that the database is making to the sysadmin
about data integrity. Everything before that time is guaranteed to have
reached data files already. Everything after it may or may not be in the data
files and has to be checked against the WAL logs.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's RemoteDBA services!

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

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:21 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 <