Skip to main content
Question

How to set file size limit for user?

  • April 23, 2019
  • 4 replies
  • 23 views

johaidii12

I want to know how to set limits by size for user. For example user get to only use up to 100mb to create their tables.

4 replies

Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • April 23, 2019

Hi,

I remember a similar question from way back in 2014!

See:
http://www.vertica-forums.com/viewtopic.php?f=4&t=1757

Example:

The directory /home/dbadmin/jim2 has a quota of 100 MB.

dbadmin=> CREATE USER jim2;
CREATE USER

dbadmin=> CREATE SCHEMA jim2;
CREATE SCHEMA

dbadmin=> CREATE LOCATION '/home/dbadmin/jim2' ALL NODES USAGE 'DATA';
CREATE LOCATION

dbadmin=>  SELECT alter_location_label('/home/dbadmin/jim2', '', 'jim2');
       alter_location_label
-----------------------------------
 /home/dbadmin/jim2 label changed.
(1 row)

dbadmin=> SELECT set_object_storage_policy('jim2', 'jim2', true);
  set_object_storage_policy
-----------------------------
 Object storage policy set.

(1 row)

dbadmin=> GRANT ALL ON SCHEMA jim2 TO jim2;
GRANT PRIVILEGE

dbadmin=> \c - jim2
You are now connected as user "jim2".

dbadmin=> CREATE TABLE jim2.my_table (c INT);
CREATE TABLE

dbadmin=> INSERT INTO jim2.my_table SELECT 1;
 OUTPUT
--------
      1
(1 row)

dbadmin=> COMMIT;
COMMIT

dbadmin=> SELECT location_label FROM storage_containers WHERE projection_name = 'my_table_super';
 location_label
----------------
 jim2
(1 row)

dbadmin=> SELECT node_name, location_path FROM storage_locations WHERE location_label = 'jim2';
     node_name      |   location_path
--------------------+--------------------
 v_test_db_node0001 | /home/dbadmin/jim2
(1 row)

See:
https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/AdministratorsGuide/StorageLocations/CreatingAndConfiguringStorageLocations.htm


johaidii12
  • Author
  • New Participant
  • April 23, 2019

Since Im kinda new to Vertica so what I get is that you create seperate directory for the schemas and then set schemas to go into that directory? Also there are no like altering options to set size for schema?


Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • April 23, 2019

I'm unaware of any ALTER command to set the max size of a table. My proposed "work around" of having a "separate directory and storage policy for each user schema" would become a maintenance nightmare if you have a lot of users! Another option might be to run an audit report via crontab once or twice a day checking for overages. You can send an email alert or lock user accounts with overages. Or you can just let users know how to manage and be "responsible" for their own space usage.

I'm curious. Why are you looking to enforce such a constraint? Hopefully you do not permit users to create tables on a production cluster on their own.


johaidii12
  • Author
  • New Participant
  • April 23, 2019

Company wants me to add restrict of 100mb to each user and since we have lot of users your workaround isn't best solution for me. However I will talk to the leaders tomorrow and maybe we can come up with better solution.