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, 07:26 AM
Sergey E. Koposov
 
Posts: n/a
Default SOC & user quotas

Hello hackers,

I was starting to think about next SOC and the project for it. And for a
long time I wanted to implement the user quotas in PG.
So, I'll try to explain my understanding of the implementation, and I'll
be happy to hear any comments, objections, or pointings to my
misunderstanding. This is very first very rough idea, but I still would
like to hear whether it contains some obvious flaws...

1) The main idea is to implement the per-user quota (not per tablespace
for example). So, during the creation of the new user some quota can be
specified, and after that the size of all the relations *owned* by that
user should be limited by that number.

2) I looked into the code, and from my understanding, the main part of the
code which should be affected by the quotas is storage/smgr/md.c. If I
understand correctly, only functions like mdcreate & mdextend really
change the size of the user relations (I don't consider things like WAL,
and I don't think it should be subject for quota). And it seems to me,
that the machinery of smgr/md is moreless enough to control the space
occupied by the relations (within some 1 block size precision).

3) How the quota should be controlled: I think, that generally, for all
the users which have quotas, the shared memory should contain the number
of blocks left from the quota. And each backend extending or truncating
the relations owned by the user should appropriately change that number of
blocks left in the shared memory. As soon as this number is equal to
zero, all the mdcreate, mdextend functions shouldn't do anything but
return the error. I don't know, but I hope these functions won't be
invoked if the user will do DELETE and/or VACUUM to recover the space ?
Also, I'm not completely sure that refusing the call of the mdextend
function in the case of quota excess won't lead to any corruption ? (in
the case of Btree splits for example ).

Any comments ?
Thank you.

Regards,
Sergey

************************************************** *****************
Sergey E. Koposov
Max Planck Institute for Astronomy/Cambridge Institute for Astronomy/Sternberg Astronomical Institute
Tel: +49-6221-528-349
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math@sai.msu.ru

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 07:26 AM
Tom Lane
 
Posts: n/a
Default Re: SOC & user quotas

"Sergey E. Koposov" <math@sai.msu.ru> writes:
> 1) The main idea is to implement the per-user quota (not per tablespace
> for example). So, during the creation of the new user some quota can be
> specified, and after that the size of all the relations *owned* by that
> user should be limited by that number.


This seems impractical as stated; there is no way to determine what a
user owns in some other database. Possibly you could do it if the quota
were both per-user and per-database.

> 2) I looked into the code, and from my understanding, the main part of the
> code which should be affected by the quotas is storage/smgr/md.c.


md.c is too low level to do catalog accesses and thus too low level to
know who owns what.

> 3) How the quota should be controlled: I think, that generally, for all
> the users which have quotas, the shared memory should contain the number
> of blocks left from the quota. And each backend extending or truncating
> the relations owned by the user should appropriately change that number of
> blocks left in the shared memory.


What will you do with ALTER TABLE OWNER? What if such a command is
rolled back? (Likewise for some other commands such as TRUNCATE, or
even just DROP TABLE.) What if there are too many users to fit in your
(necessarily fixed size) shared memory area? What sort of contention
will there be for access to this area?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 07:26 AM
Joshua D. Drake
 
Posts: n/a
Default Re: SOC & user quotas

Sergey E. Koposov wrote:
> Hello hackers,
>
> I was starting to think about next SOC and the project for it. And for a
> long time I wanted to implement the user quotas in PG.
> So, I'll try to explain my understanding of the implementation, and I'll
> be happy to hear any comments, objections, or pointings to my
> misunderstanding. This is very first very rough idea, but I still would
> like to hear whether it contains some obvious flaws...
>
> 1) The main idea is to implement the per-user quota (not per tablespace
> for example). So, during the creation of the new user some quota can be
> specified, and after that the size of all the relations *owned* by that
> user should be limited by that number.


I could see this being useful per database, maybe. It seems like kind of
an odd feature.

Sincerely,

Joshua D. Drake


--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/


---------------------------(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
  #4 (permalink)  
Old 04-12-2008, 07:26 AM
Sergey E. Koposov
 
Posts: n/a
Default Re: SOC & user quotas

On Wed, 28 Feb 2007, Tom Lane wrote:

> "Sergey E. Koposov" <math@sai.msu.ru> writes:
>> 1) The main idea is to implement the per-user quota (not per tablespace
>> for example). So, during the creation of the new user some quota can be
>> specified, and after that the size of all the relations *owned* by that
>> user should be limited by that number.

>
> This seems impractical as stated; there is no way to determine what a
> user owns in some other database. Possibly you could do it if the quota
> were both per-user and per-database.


yes, agreed. I didn't think of that.

>> 3) How the quota should be controlled: I think, that generally, for all
>> the users which have quotas, the shared memory should contain the number
>> of blocks left from the quota. And each backend extending or truncating
>> the relations owned by the user should appropriately change that number of
>> blocks left in the shared memory.

>
> What will you do with ALTER TABLE OWNER? What if such a command is
> rolled back?


I don't know, but I guess the ALTER OWNER should be considered
differently. It probably should proceed only if it sees that there are
enough place to perform the whole operation. If there are, then it should
block any writing to the tables of the user, perform the alter owner and
unblock everything again.

> (Likewise for some other commands such as TRUNCATE, or
> even just DROP TABLE.)


I didn't think of yet, but I will.

> What if there are too many users to fit in your
> (necessarily fixed size) shared memory area?


We really don't need to create the array for all users. We only need to
create that array for users 1) having quotas 2) the users,
whose tables are accessed at the moment
So I don't think that in that case the amount of required space is a
problem here.

> What sort of contention
> will there be for access to this area?


I think, that the only requirement is that the incrementation or
decrementation of number of blocks left for each user
should be atomic operation.

regards,
Sergey

************************************************** *****************
Sergey E. Koposov
Max Planck Institute for Astronomy/Cambridge Institute for Astronomy/Sternberg Astronomical Institute
Tel: +49-6221-528-349
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math@sai.msu.ru

---------------------------(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
  #5 (permalink)  
Old 04-12-2008, 07:27 AM
Sergey E. Koposov
 
Posts: n/a
Default Re: SOC & user quotas

On Wed, 28 Feb 2007, Joshua D. Drake wrote:

> I could see this being useful per database, maybe. It seems like kind of
> an odd feature.


Per user AND per database (as Tom noted). But I dont see what's odd in
it... It exists in Oracle, and I need quotas in the project on which I'm
working. And I remember user requests for quotas in the mailing lists ...

regards,
Sergey

************************************************** *****************
Sergey E. Koposov
Max Planck Institute for Astronomy/Cambridge Institute for Astronomy/Sternberg Astronomical Institute
Tel: +49-6221-528-349
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math@sai.msu.ru

---------------------------(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
  #6 (permalink)  
Old 04-12-2008, 07:27 AM
Joshua D. Drake
 
Posts: n/a
Default Re: SOC & user quotas

Sergey E. Koposov wrote:
> On Wed, 28 Feb 2007, Joshua D. Drake wrote:
>
>> I could see this being useful per database, maybe. It seems like kind of
>> an odd feature.

>
> Per user AND per database (as Tom noted). But I dont see what's odd in
> it... It exists in Oracle, and I need quotas in the project on which I'm
> working. And I remember user requests for quotas in the mailing lists ...


Well Oracle isn't really our goal is it? I am not questioning that you
are well intended but I just don't see a use case.

For example, what happens if I hit my quota?

Joshua D. Drake

>
> regards,
> Sergey
>
> ************************************************** *****************
> Sergey E. Koposov
> Max Planck Institute for Astronomy/Cambridge Institute for
> Astronomy/Sternberg Astronomical Institute
> Tel: +49-6221-528-349
> Web: http://lnfm1.sai.msu.ru/~math
> E-mail: math@sai.msu.ru
>
> ---------------------------(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
>



--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/


---------------------------(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
  #7 (permalink)  
Old 04-12-2008, 07:27 AM
Sergey E. Koposov
 
Posts: n/a
Default Re: SOC & user quotas

On Wed, 28 Feb 2007, Joshua D. Drake wrote:

> Sergey E. Koposov wrote:
>> On Wed, 28 Feb 2007, Joshua D. Drake wrote:
>> Per user AND per database (as Tom noted). But I dont see what's odd in
>> it... It exists in Oracle, and I need quotas in the project on which I'm
>> working. And I remember user requests for quotas in the mailing lists ...

>
> Well Oracle isn't really our goal is it? I am not questioning that you
> are well intended but I just don't see a use case.
>
> For example, what happens if I hit my quota?


Then you cannot run any queries that extend the size of your relations
(for example INSERT, UPDATE etc.). Unless you drop your tables or DELETE
something

The use case for that is the situation when you provide the access to
different people to do something on the DB. The real world example (in
which I'm interested) is when the large science project produce a huge
amount of data, store it in large database, and let different scientists
work on that data, having their little accounts there. (example
http://casjobs.sdss.org/CasJobs/Guide.aspx ). That's the way how most of
large astronomical projects start to work now.

Regards,
Sergey

************************************************** *****************
Sergey E. Koposov
Max Planck Institute for Astronomy/Cambridge Institute for Astronomy/Sternberg Astronomical Institute
Tel: +49-6221-528-349
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math@sai.msu.ru

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-12-2008, 07:27 AM
Joshua D. Drake
 
Posts: n/a
Default Re: SOC & user quotas


> Then you cannot run any queries that extend the size of your relations
> (for example INSERT, UPDATE etc.). Unless you drop your tables or DELETE
> something


Interesting. Well my two cents is don't go any deeper than database.
I.e; don't try and track to the individual relation.

Joshua D. Drake


>
> The use case for that is the situation when you provide the access to
> different people to do something on the DB. The real world example (in
> which I'm interested) is when the large science project produce a huge
> amount of data, store it in large database, and let different scientists
> work on that data, having their little accounts there. (example
> http://casjobs.sdss.org/CasJobs/Guide.aspx ). That's the way how most of
> large astronomical projects start to work now.
>
> Regards,
> Sergey
>
> ************************************************** *****************
> Sergey E. Koposov
> Max Planck Institute for Astronomy/Cambridge Institute for
> Astronomy/Sternberg Astronomical Institute
> Tel: +49-6221-528-349
> Web: http://lnfm1.sai.msu.ru/~math
> E-mail: math@sai.msu.ru
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>



--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/


---------------------------(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
  #9 (permalink)  
Old 04-12-2008, 07:27 AM
Tom Lane
 
Posts: n/a
Default Re: SOC & user quotas

"Sergey E. Koposov" <math@sai.msu.ru> writes:
> Per user AND per database (as Tom noted). But I dont see what's odd in
> it... It exists in Oracle, and I need quotas in the project on which I'm
> working. And I remember user requests for quotas in the mailing lists ...


It hasn't ever made it onto the TODO list, which means there's not a
consensus that we need it. If it were a simple, small, low-impact patch
then you probably wouldn't need to do much convincing that it's an
important feature to have, but I'm afraid the patch will be none of
those things.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-12-2008, 07:27 AM
Joshua D. Drake
 
Posts: n/a
Default Re: SOC & user quotas

Tom Lane wrote:
> "Sergey E. Koposov" <math@sai.msu.ru> writes:
>> Per user AND per database (as Tom noted). But I dont see what's odd in
>> it... It exists in Oracle, and I need quotas in the project on which I'm
>> working. And I remember user requests for quotas in the mailing lists ...

>
> It hasn't ever made it onto the TODO list, which means there's not a
> consensus that we need it. If it were a simple, small, low-impact patch
> then you probably wouldn't need to do much convincing that it's an
> important feature to have, but I'm afraid the patch will be none of
> those things.


Tom what about at just the DB level?

E.g; if user foo then pg_database_size may not be > than X?

I guess the big question would be when do we check though? At each
transaction seems like it would add significant overhead, especially if
we had to rollback the transaction because it was going to go over their
quota.

Egad.

Joshua D. Drake



>
> regards, tom lane
>



--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

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:13 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 5