table of contentsgpcc.docs.pivotal.io/pdf/gp-wlm-170-user-guide.pdf · checking the health of...

39
1 2 3 5 7 10 12 13 18 20 22 24 25 26 28 30 33 35 36 Table of Contents Table of Contents About Greenplum Workload Manager Installing Greenplum Workload Manager Managing Greenplum Workload Manager Services Using the Greenplum Workload Manager Command Line Using the Workload Manager Graphical Interface (gptop) Using Workload Manager Rules Understanding Rules Adding Rules Managing Rules Example Rules Best Practices for Rules Known Issues Querying Workload Manager Record Data Querying Workload Manager Event Data Managing Resource Queues Configuring Workload Manager Components Troubleshooting Workload Manager Datum Reference © Copyright Pivotal Software Inc, 2013-2017 1 1.7.0

Upload: others

Post on 28-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

12357

1012131820222425262830333536

TableofContents

TableofContentsAboutGreenplumWorkloadManagerInstallingGreenplumWorkloadManagerManagingGreenplumWorkloadManagerServicesUsingtheGreenplumWorkloadManagerCommandLineUsingtheWorkloadManagerGraphicalInterface(gptop)UsingWorkloadManagerRulesUnderstandingRulesAddingRulesManagingRulesExampleRulesBestPracticesforRulesKnownIssuesQueryingWorkloadManagerRecordDataQueryingWorkloadManagerEventDataManagingResourceQueuesConfiguringWorkloadManagerComponentsTroubleshootingWorkloadManagerDatumReference

©CopyrightPivotalSoftwareInc,2013-2017 1 1.7.0

Page 2: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

AboutGreenplumWorkloadManagerGreenplumWorkloadManagerisamanagementtoolforGreenplumDatabaseyoucanusetomonitorandmanagequeriesandtomanageresourcequeues.

YoucanuseGreenplumWorkloadManagertoperformtaskslikethese:

MonitorGreenplumDatabasequeriesandhostutilizationstatistics

Logwhenaqueryexceedsathreshold

ThrottletheCPUusageofaquerywhenitexceedsathreshold

Terminateaquery

Detectmemory,CPU,ordiskI/Oskewoccurringduringtheexecutionofaquery

Createdetailedrulestomanagequeries

Add,modify,ordeleteGreenplumDatabaseresourcequeues

WorkloadManagerArchitectureGreenplumWorkloadManagerisasetofGreenplumDatabase-specificpluginsdeployedonanextensiblePivotalframework.Alloftheapplicationlogicisisolatedintheseplugins.WorkloadManagerprovidesthefollowingplugins:

Agentplugins:

PublishinformationaboutactiveGreenplumDatabasequeries

Publishinformationaboutpostgresprocesses

Advertisequeryterminationcapability

Advertisequerythrottlingcapability

Advertisethresholdloggingcapability

Configurationmanagementplugins:

QuerythestateoftheGreenplumDatabaseclusterperiodically

InformtheframeworkoftheGreenplumDatabaseclusterstateandsizeallowing gp-wlm toautomaticallygrowwhenthedatabaseisexpanded.

Deployconfigurationsthroughoutthecluster.

Command-lineinterfaceplugins:

Add,modify,ordeleterules

Monitorqueriesandskew

ManageGreenplumDatabaseresourcequeues

Rulesengineplugins:

Provideextendedfunctionalityusedduringrulescreation

Theruntimeframeworkloadsthesepluginsatexecutiontime.

©CopyrightPivotalSoftwareInc,2013-2017 2 1.7.0

Page 3: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

InstallingGreenplumWorkloadManager

PrerequisitesRedHatEnterpriseLinux(RHEL)64-bit5.5+or6,CentOS64-bit5.5+or6,orSUSE11

GreenplumDatabaseversion4.3.x

PivotalGreenplumCommandCenterinstallerforyourplatform

Note:TheGreenplumWorkloadManagerinstallersareincludedinthePivotalGreenplumCommandCenterinstalleryoudownloadfromPivotalNetwork .Theinstallerfile, gp-wlm-<version>-<platform>.bin ,isintheGreenplumCommandCenterinstallationdirectory, /usr/local/greenplum-cc-web ,bydefault.

RunningtheGreenplumWorkloadManagerInstallerGreenplumWorkloadManagerisinstalledontheGreenplumDatabasemasternode.Itautomaticallydistributesthesoftwaretoallsegmentserversinthedatabasecluster.TheinstallerdetectstheinstalledWorkloadManagerversion,ifany,andperformsanupgradeifnecessary.Runtheinstallerwiththe--force optiontoforcereinstallationofthecurrentversion.

Thepackageinstallerhasthefollowingsyntax:

./gp-wlm-<version>-<platform>.bin--help

./gp-wlm-<version>-<platform>.bin--install=<DIR>[--force][--install-concurrency=<COUNT>][--no-remove-old][--skip-health-check][--dbname-records=<database_name>][--tool-manifest=<FILE>]

Options

--help

DisplayscommandsyntaxfortheWorkloadManagerinstaller.

--install=DIR

The --install optionisrequired.ItspecifiesthedirectorywhereGreenplumWorkloadManagerwillbeinstalled,forexample /home/gpadmin .

--force

Ifthe --install optionpointstoanexistingGreenplumWorkloadManagerinstall,theinstallerwillcheckthecurrentlyinstalledversionandperformanupgradeonlyifthecurrentversionisolderthantheversionbeinginstalled.Ifthe --force optionisspecified,theinstallerwillallowinstallingthesameversionofGreenplumWorkloadManagerontopofitself.Notethat --force doesnotallowyoutodowngradeGreenplumWorkloadManagertoanearlierversion.

--install-concurrency=COUNT

Themaximumnumberofhoststobootstrapatonce.Thedefaultcountiscomputedbytheinstaller.Thisoptionplacesalimitonthenumberofprocessestheinstallercanfork.

--no-remove-old

Bydefault,theinstallerremovesallpreviousinstallationdirectoriesafteranupgrade.The --no-remove-old optionpreventstheinstallerfromremovingoldinstallationdirectories.

--skip-health-check

DonotperformaclusterhealthcheckafterWorkloadManagerinstallationcompletes.Thisoptionisnotrecommended.

--dbname-records

Thenameofthedatabasewherethe gp_wlm_records tableiscreated.Thedefaultispostgres.The template0 and template1 databasesmaynotbespecified.Thedatabasemustexistatinstalltime.ThesamedatabasemustbespecifiedwhenupgradingtoanewWorkloadManagerrelease.

--tool-manifestfilename

Theoptional --tool-manifest optionspecifiesatextfilecontainingalistofcommandsandtheirabsolutepaths.WorkloadManagernormallyfindsstandardsystemcommandsonthepath.Ifyourenvironmenthasincompatibleimplementationsofthesecommandsonthepath,createamanifestfilethatprovidestheabsolutepathtoastandardversion.

©CopyrightPivotalSoftwareInc,2013-2017 3 1.7.0

Page 4: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

Followingisanexampletoolsmanifestfile:

stat=/home/gpadmin/bin/statreadlink=/bin/readlinkssh=/home/me/bin/myssh

Theinstallercreatesa gp-wlm-data directoryintheinstallationdirectoryandinstallstheGreenplumWorkloadManagerreleaseintoit.Asymboliclinkgp-wlm intheinstallationdirectorylinkstothespecificGreenplumWorkloadManagerreleasedirectory.

1. LogintotheGreenplummasterhostasthe gpadmin user.

2. EnsurethattheGreenplumWorkloadManagerinstallerisexecutable.

$chmod+xgp-wlm-<version>-<platform>.bin

3. RuntheGreenplumWorkloadManagerinstaller.Specifytheabsolutepathtoaninstallationdirectorywhereyouhavewritepermission.Forexample:

$./gp-wlm-<version>-<platform>.bin--install=/home/gpadmin/

ThiscommandinstallsGreenplumWorkloadManagerinthe gp-wlm-data subdirectoryonallofthesegmentsandcreatesthe gp-wlm symboliclink.Forexample,theabovecommandinstallsWorkloadManagerin /home/gpadmin/gp-wlm-data/gp-wlm-release andcreatesthesymboliclink /home/gpadmin/gp-

wlm .

Note:Inrarecases,theinstallercanfailduringthe cluster-health-check phase.Iftheclusterisreportednothealthy,re-runtheinstallerwiththe --force option.

4. ToaddtheWorkloadManagerexecutablestoyourpath,source <INSTALL_DIR>/gp-wlm/gp-wlm_path.sh inyourshell.

$source<INSTALL_DIR>/gp-wlm/gp-wlm_path.sh

Youcanaddthe source commandtoyour ~/.bash_profile or ~/.bashrc scripttoincludetheWorkloadManagerexecutablesinyourpathwheneveryoulogin.

UninstallingGreenplumWorkloadManagerTouninstallGreenplumWorkloadManager,runthefollowingcommand:

$<INSTALL_DIR>/gp-wlm/bin/uninstall--symlink<INSTALL_DIR>/gp-wlm

©CopyrightPivotalSoftwareInc,2013-2017 4 1.7.0

Page 5: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

ManagingGreenplumWorkloadManagerServicesGreenplumWorkloadManagerinstallsandrunsfourservicesonallsegmenthostsintheGreenplumcluster:

agent

cfgmon

rabbitmq

rulesengine

Theservicescanbemanagedusingthe INSTALLDIR/gp-wlm/bin/svc-mgr.sh command.Thecommandhasthefollowingsyntax:

INSTALLDIR/gp-wlm/bin/svc-mgr.sh\--service=SVCNAME\--action=ACTION

SVCNAME maybe agent , cfgmon , rabbitmq , rulesengine ,or all .If SVCNAME specifiesanindividualservice,onlythatserviceismodified.Specify alltomanipulateallservices.

The ACTION parameteraffectsonlythelocalsystem,unlessitisprefixedwith cluster- ,inwhichcaseitrunsonallhostsinthecluster.Theactionsare:

start / cluster-start –StartanyoftheWorkloadManagerservicesthatarenotrunning.

stop / cluster-stop –StopanyWorkloadManagerservicesthatarerunning.

status / cluster-status –Determineiftheservicesarerunning.

restart / cluster-restart –RestarttheWorkloadManagerservices.

enable / cluster-enable –EnableandstartWorkloadManagerservices.

disable / cluster-disable –StopanddisableWorkloadManagerservices.

Ifyousourcethe INSTALLDIR/gp-wlm/gp-wlm_path.sh fileinyourshell,theWorkloadManagerscriptsareinyourpath.Otherwise,youmustprovidethefullpathtotheutilityinthe gp-wlm/bin directory.

Whenaserviceisstopped,itwillnotberestarteduntilthe start actionisinvoked,orthelocalmachinereboots,whichevercomesfirst.

Whenaserviceisdisabled,itwillnotberestarteduntilthe enable actionisinvoked.Thisispersistentacrossreboot.

ThefollowingexamplechecksthestatusofallWorkloadManagerservicesonthelocalhost:

[gpadmin@mdw~]$svc-mgr.sh--service=all--action=statusRabbitMQisrunningoutofthecurrentinstallation.(PID=22541)agent(pid22732)isrunning...cfgmon(pid22858)isrunning...rulesengine(pid22921)isrunning...

CheckingtheHealthofGreenplumWorkloadManagerServicesAtanytime,thehealthofGreenplumWorkloadManagerservicescanbeverifiedacrosstheclusterbyinvokingthecluster-health-check utility.Thistoolconfirmsthatallservicesarerunningacrossthecluster,andthatmessagesarebeingreceivedfromeachmachineinthecluster.Followingisthesyntaxfor cluster-health-check :

INSTALLDIR/gpwlm/bin/cluster-health-check--symlink=/absolute/path/to/installation/symlink[--max-concurrency=N][--max-cluster-checks=N][--help]

Options: -c or --max-concurrency

The max-concurrency optionspecifiesthenumberofhoststocheckatonce.Thedefaultisacomputedvaluebasedonthenumberofhostsinthecluster:20iftherearefewerthan100hosts,50ifthereare100to199hosts,and75ifthereare200ormorehosts.

-m or --max-cluster-checks

Thenumberoftimestocheckforahealthycluster.Thedefaultis1.

©CopyrightPivotalSoftwareInc,2013-2017 5 1.7.0

Page 6: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

-s or --symlink

Theabsolutepathtothe gp-wlm directorylinkedtotheinstalledWorkloadManagerrelease.Required.

-h or --helpDisplaycommandusageinformationandexit.

Ifthecommandreportsanerrorcommunicatingwithoneormoreservices,theclustermayberestartedwiththiscommand:

INSTALLDIR/gp-wlm/bin/svc-mgr.sh--action=cluster-restart--service=all

ThiscommandstopsandthenrestartseachoftheWorkloadManagerservicesoneachsegmenthost.

©CopyrightPivotalSoftwareInc,2013-2017 6 1.7.0

Page 7: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

UsingtheGreenplumWorkloadManagerCommandLineTheGreenplumWorkloadManagercommandlineutility, gp-wlm ,providesaccesstoWorkloadManagercapabilities.Theutilitymayberunbyenteringcommandsinteractivelyorbyspecifyingequivalentactionsusingcommand-lineoptions.Thecommand-lineoptionsareusefulforscripting,sincetheyrequirenointeractiveuserinput.

Togethelpininteractivemode,issuethecommand: help

Togethelpforcommandlineinvocation,issuethecommand: gp-wlm--help

Belowisthe gp-wlm commandsyntax:

Usage:gp-wlm[-g|gptop][--rq-add=<queue-name>with<queue-settings>][--rq-delete=<queue-name>][--rq-modify=<queue-name>with<queue-settings>][--rq-show=all][--rq-useradd=<user>to<queue-name>][--rq-userdel=<user>from<queue-name>][--rule-add=[transient]<name><rule>][--rule-delete=all|<name>][--rule-dump=<path>][--rule-import=<path>][--rule-modify=[transient]<name><rule>][--rule-restore=<path>][--rule-show=all|<name>[<host><domain>]][--describe=<datum>][--config-show<component><setting>][--config-describe<component><setting>][--config-modify<component><setting>=<value>][--set-domain=<domain>][--set-host=<host>][--schema-path=<path>][--version][--help][--usage]

The gp-wlm command-lineoptionshaveparallelcommandsinthe gp-wlm interactivemode.Theoptiondescriptionsbelowlinktotheinteractivemodecommandsforadditionalusageinformationandexamples.

Options

-g or --gptopStartsthe gptop graphicaluserinterface.SeeUsingtheWorkloadManagerGraphicalInterface(gptop)formoreabout gptop .

--rq-addAddsaresourcequeuewiththespecifiednameandsettings.SeeResourceQueueSettingsfortheformatandcontentofthe<queue-settings>argument.

--rq-deleteDeletestheresourcequeuewiththespecifiedname.SeeDeletingaResourceQueueforinformationaboutdeletingresourcequeues.

--rq-modifyChangesthesettingsfortheresourcequeuewiththespecifiednametothespecifiedsettings.SeeResourceQueueSettingsfortheformatandcontentofthe<queue-settings>argument.

--rq-show=allOutputsalistofresourcequeuesandsettings.SeeDisplayingResourceQueuesforanexampleoftheoutput.

--rq-useraddAddsadatabaseroletoaresourcequeue.Arolecanbelongtooneresourcequeueatatime.SeeAddingUserstoResourceQueuesfordetailsandexamples.

--rq-userdelDeletesadatabaserolefromaresourcequeue.SeeDeletingaUserfromaResourceQueuefordetailsandexamples.

--rule-addAddsaruletotherulesengine.SeeAddingRulesfordetailsaboutthepartsofaruleandexamples.

--rule-deleteDeletesarulewithaspecifiednameor,byusingthereservedname all ,allcurrentrules.SeeDeletingRulesfordetailsandexamples.

--rule-dumpSavesthecurrentsetofpermanentrulestoanamedfile.SeeSavingRulestoDiskfordetailsandexamples.

©CopyrightPivotalSoftwareInc,2013-2017 7 1.7.0

Page 8: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

--rule-importAddsrulessavedinanexternalfiletothecurrentruleset.SeeImportingRulesfordetailsandexamples.

--rule-modifyModifiesarulebyreplacingtheruleexpressionormakingatransientrulepermanent.SeeModifyingRulesfordetails.

--rule-restoreRestorerulesfromanexternalfile,replacingthecurrentrulesintherulesengine.SeeRestoringRulesfordetails.

--rule-showDisplayarulebynameor,byusingthereservedname all ,allcurrentrules.SeeDisplayingRulesfordetailsandexamples.

--config-showShowthecurrentvalueofasettingforaWorkloadManagercomponent.SeeConfiguringWorkloadManagerComponentsfordetailsabouttheconfigurationcommands.

--config-describeDescribethepurposeofasettingforaWorkloadManagercomponentanditsvalueconstraints.

--config-modifyOverridethevalueofasettingforaWorkloadManagercomponent.Thecomponentisautomaticallyrestartedafterasettingisupdated.

--set-domainSetthedomain,orclustername,forthe gp-wlm interactivesession.Itisrecommendedtousethedefaultdomain.

--set-hostSetthehostwherethe gp-wlm sessionruns.Thedefaultisthemachinewhereyourun gp-wlm .Itisrecommendedtoonlyrun gp-wlm ontheGreenplummasterhost.

--schema-pathThepathtotheschemafiles.Thedefaultpath, INSTALLDIR/schema ,shouldnotbechanged.

--usageDisplaysusageinformationforthe gp-wlm command.

--helpDisplaysonlinehelpforthe gp-wlm command.

--describeDisplaysadescriptionofadatum.Forexample:

$gp-wlm--describe=datid:numbackends

--version or -vDisplaysthe gp-wlm version.

Usinggp-wlminInteractiveMode1. Startgp-wlmatthecommandline:

$gp-wlm

The gp-wlm commandpromptdisplaysthenameofthehostwhere gp-wlm isrunningandthenameoftheGreenplumDatabaseclusterordomain.Enter help attheinteractivepromptforausagemessage.

Whenusingthe gp-wlm command-line:

Entereachcommandonasingleline.Commandsareexecutedimmediately.

Enterthe help commandtoviewalistofWorkloadManagercommands.

Enter describe <datum> toviewadescriptionofadatum.

Whileenteringacommand,gethelpwithcommandsyntaxbypressingthetabkeytoshowvalidoptions.Thisisespeciallyusefulwhenconstructingarule.Inthefollowingpartialexample,userentryisinbold.

©CopyrightPivotalSoftwareInc,2013-2017 8 1.7.0

Page 9: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

mdw/gpdb-cluster>rule<tab>adddeletedumpmodifyrestoreshowmdw/gpdb-cluster>ruleadd<tab><rule-name>transientmdw/gpdb-cluster>ruleaddtransient<tab><rule-name>mdw/gpdb-cluster>ruleaddtransientmyrule<tab>gpdb_recordhost:pg_terminate_backendmdw/gpdb-cluster>ruleaddtransientmyrulegpdb_record(<tab><dt>)gpdb_segment_rolemessagequery_startusename</dt>current_queryhostpidsession_id...

Enterthequitcommandattheprompttoexitthe gp-wlm interactivemode.

SettingtheWorkloadManagerTargetHostandDomainUsethe sethost and setdomain commandstosetthedefaulthostanddomainfortheWorkloadManagersession.

Itisrecommendedtoonlyrunthe gp-wlm toolontheGreenplumDatabasemasternodeandtoleavethehostanddomainattheirdefaultvalues.

Thedefaulthostisthenameofthemachinewhereyouexecute gp-wlm .ThehostnamemustberesolvableinDNS.Youcanspecifydifferenthostandclusternamesonthe gp-wlm commandlinebysupplyingthe --set-host and --set-domain commandlineoptions.

Example:

mdw/gpdb-cluster>sethostsmdwsmdw/gpdb-cluster>setdomaingpdbsyssmdw/gpdbsys>

©CopyrightPivotalSoftwareInc,2013-2017 9 1.7.0

Page 10: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

UsingtheWorkloadManagerGraphicalInterface(gptop)TheWorkloadManagerGraphicalinterface, gptop ,isacursesinterfacethatyoucanusetomonitorlivedatafortherulesengine,hoststatistics,activeGreenplumDatabasequeries,anddatabaseskew.

Youcanstart gptop fromthecommandlinebyrunning gptop inaterminal.Ifyouarealreadyusinginteractive gp-wlm ,enterthe gptop commandtoenterthemonitor.

Note:IfyouusethePuTTYssh/telnetclientforWindowstorun gptop ,youmayexperienceproblemswithfunctionkeysandline-drawingcharacterswiththedefaultsettings.Tosupportfunctionkeys,inthePuTTYConfigurationwindow,chooseConnection>Dataandenter xterm-color or putty intheTerminal-typestringfield.Toenablecorrectline-drawingcharacters,chooseWindow>TranslationandsetRemotecharactersettoUsefontencoding.

Whenyoufirststart gptop ,theGPDBQueriespane(seebelow)isselected.Atanytime,youcanpresstheF2keytogetapaneselectionmenu.UsetheTab,Left-Arrow,orRight-Arrowkeystomakeaselection.PressF2tocloseanopenmenuwithoutmakingaselection.

Anasterisk( * )nexttoacolumnheadingindicatesthattherowsaresortedbythatcolumn.Tochangethesortorder,presstheF3key,thenchoosethenumberofthecolumnyouwanttosortbyfromthepop-upmenu.

Press q orchooseFile>Exittoleave gptop .

The gptop monitoringfeaturesareundertheMonitormenu.TheMonitormenuhasfouroptions:

GPDBQueries–ShowsactiveGreenplumDatabasequeries

GPDBSkew–Showsskewstaticsforactivequeries

Hydra–Showsstatisticsfromtherulesengine

SysData–Showsperformancestatisticsforeachhostinthecluster

GPDBQueriesTheGPDBQueriesmonitordisplaysalineforeachactiveGreenplumDatabasequery.

SessIDThesessionidforthequery.

TimeThenumberofsecondssincethequerybeganexecuting.

UserThenameoftheGreenplumDatabaserolethatsubmittedthequery.

ClientAddrThenetworkaddressfromwhichthequerywassubmitted.

DatNameThedatabasenamethequeryisrunningagainst.

QueryThetextofthequery.

GPDBSkewTheGPDBSkewmonitorshowscalculatedskewstatisticsforactiveGreenplumDatabasequeries.Statisticsarecalculatedoneachhostinthesystemandthensenttothemasterwheretheyaresummarized.YoucanselectahostandpressEntertoseestatisticsforthehost.Thecalculatedskewvalueisthecubedstandarddeviationacrossthecluster.Valuescloserto0.0indicatelessskew.TheGPDBSkewmonitorshowsthefollowingcolumnsforeachactivequery:

SessIDTheGreenplumDatabasesessionIDforthequery.

©CopyrightPivotalSoftwareInc,2013-2017 10 1.7.0

Page 11: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

TimeThenumberofsecondssincethequerystarted.

UserTheGreenplumDatabaserolethatsubmittedthequery.

CPU-SkewAmeasureofCPUskewcalculatedasthecubedstandarddeviationofthetotalCPUforeachhostforthequery.

MEM-SkewAmeasureofmemoryskewcalculatedasthecubedstandarddeviationofthetotalresidentsizepercentforeachhostforthequery.

READ-SkewAmeasureofdiskreadI/Oskewcalculatedasthecubedstandarddeviationofthebytesreadpersecondforeachhostforthequery.

WRITE-SkewAmeasureofdiskwriteI/Oskewcalculatedasthecubedstandarddeviationofthebyteswrittenpersecondforeachhostforthequery.

©CopyrightPivotalSoftwareInc,2013-2017 11 1.7.0

Page 12: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

UsingWorkloadManagerRulesRulestriggeractionswhentheymatchevents.Theagentpluginsonthesegmenthostscollectstatisticsandassociateddata.Therulesenginematchesthemtorules,andperformsthespecifiedactionsintheagentplugins.

UnderstandingRules

AddRuleCommandSyntax

ManagingRules

ExampleRules

BestPracticesforRules

KnownIssues

©CopyrightPivotalSoftwareInc,2013-2017 12 1.7.0

Page 13: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

UnderstandingRulesThistopicprovidesanintroductiontoWorkloadManagerrulesincludinghowtowritethemandhowtheybehaveinaGreenplumDatabaseclusterwithWorkloadManager.

RulesOverviewAWorkloadManagerrulespecifiesanactiontoexecutewhenaspecifiedconditionisdetectedintheGreenplumDatabasecluster.AdministratorswriteWorkloadManagerrulestoinvestigateproblemqueries,throttlequeriesthatconsumetoomuchCPU,orsimplyterminatequeriesthatcoulddisruptthedatabasesystem.

The rulesengine serviceoneachGreenplumhostevaluatesrulesagainstfacts,calleddatums,collectedfromtheGreenplumhostoperatingsystemsanddatabaseprocesses.Atregularintervals,datumsarecollectedandsubmittedtothe rulesengine serviceoneachhost.Whentherulesenginematchesarule,itperformsitsaction.

Arulehasanactionexpressionandaconditionexpressionseparatedbythe WHEN keyword.Itcanbereadas“do<action-exp>WHEN<condition-exp>”.

Hereisarulethatterminatesanysessionthathasrunforover120seconds:

pg_terminate_backend()whensession_id:host:pid:runtime>120

Intheaboverule,theactionexpressionis pg_terminate_backend() andtheconditionexpressionis session_id:host:pid:runtime>120

.

Theterm session_id:host:pid:runtime isascopeddatum; runtime isthenameofthedatumand session_id:host:pid isthescope.Thisscopeddatumspecifiestheelapsedexecutiontimeforaqueryexecutorprocessonasegmenthost.Thecolon-delimitedsectionsofthescopeanddatumidentifythesourceofthevalue:

session_id –IDofaGreenplumDatabasequery

host –thenameofasegmenthost

pid –processIDofaqueryexecutorprocessrunningonthehost

runtime –elapsedtimesincethequeryexecutorprocessstarted

Youcreaterulesusingthe ruleadd commandinaninteractive gp-wlm sessionorwiththe --rule-add command-lineoption.Eachrulehasauniquenameusedformanagingtherulewithcommandssuchas rulemodify or ruledelete .

Arulemayalsobelabeled transient ,whichmeanstheruleisactiveonlyuntilitisdeletedorWorkloadManagerisrestarted.

Fordetailsaboutthe ruleadd commandsyntaxandusageseeAddRules.

ForreferenceinformationaboutWorkloadManagercommandsthatmanageexistingrules(modify,delete,dump,import,andrestore),seeManagingRules.

Thenextsectionsprovidemoredetailedinformationaboutthecomponentsofarule:actionexpressions,conditionexpressions,datums,andscopes.

ActionExpressionTheactiontoperformwhenaruleistriggeredisspecifiedwithoneofthefollowingWorkloadManageractions:

gpdb_record –recordacustommessageanddetailsofthedatabasequeryprocessinthe gp_wlm_records databasetable.

host:throttle_gpdb_query –throttleaGreenplumDatabasequeryonaspecifiedhost.

host:pg_cancel_backend –cancelthecurrentqueryinasessiononahostbycallingthePostgreSQLpg_cancel_backend() function.

pg_terminate_backend –terminateasessionbycallingthePostgreSQL pg_terminate_backend() function.

Arule’sconditionexpressionalwaysidentifiesasinglequeryexecutorprocessonasingleGreenplumsegmenthost.Whenarule’sactionexecutes,itwillhaveinitscontextthequery’ssessionID,asegmenthostname,andtheprocessIDofasinglequeryexecutorprocessonthehost.

EachoftheactionsrespondstothesingleGreenplumDatabasequeryexecutorprocessidentifiedbytheconditionexpression.SeeRuleActionsforreferenceinformationfortheactions.

©CopyrightPivotalSoftwareInc,2013-2017 13 1.7.0

Page 14: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

Actionexpressionsarewrittenasfunctionsandcanhavezeroormorearguments,specifiedwith key=value pairsinparenthesesaftertheactionname:

<action-name>(<arg1>=<value1>,<arg2>=<value2>,...)

gpdb_recordThe gpdb_record actionwritesthetextspecifiedinits message argumenttoalogfile,alongwithdetailsofthedatabasequeryprocessidentifiedintherule’sconditionexpression.Forexample,the gpdb_record actioncanlogamessagewhenanyqueryprocessexceeds120seconds:

gpdb_record(message='queryruntimeexceeds120seconds')whensession_id:host:pid:runtime>120

The gp_wlm_records externalGreenplumDatabasetableprovidesSQLqueryaccesstotheloggedrecords.(SeeQueryingthegp_wlm_recordsTable formoreinformation.)

The gpdb_record actionhasseveralarguments,butonlythe message argumentisrequiredtobespecifiedintherule.Hereisthefulllistofargumentsforthisaction:

message –Informativestringdescribingthereasonforrecording

current_query -Thetextofthecurrentquery

gpdb_segment_role -Roleofthedatabaseinstance: GPDB_MASTER or GPDB_SEGMENT

host -Thehostnameofthesegment

pid -Thepostgresprocessassociatedwiththequery

query_start -Querystarttime

session_id -Sessionidofthequery

usename -Nameoftheuserloggedintothisbackend

Withtheexceptionof message ,avalueforeachoftheseargumentsisinferredfromthematchedqueryprocess. gpdb_record logsarecordthatincludesthesuppliedmessage,alloftheseinferredvalues,thetextoftherule,andcontextvaluesfromtheconditionexpression.

host:throttle_gpdb_queryThe host:throttle_gpdb_query actionholdsaquerytoamaximumshareofCPUonahost,specifiedinthemax_cpu argumentasapercentageofCPUutilization.

The host: prefixonthe host:throttle_gpdb_query actionisascope.The host: scopeindicatesthattheactionwillbeperformedonlyonthehostmachineswheretherule’sconditionismatched.The host:throttle_gpdb_query actioniscurrentlytheonlyscopedaction.(Datumsusedintheconditionexpressionareallscoped.SeeDatumsandScopesbelowfordetails.)

This host:throttle_gpdb_query rulethrottlesaqueryonahostto30%CPUutilization:

host:throttle_gpdb_query(max_cpu=30)whensession_id:host:total_cpu>20

The session_id:host:total_cpu scopeddatumisthetotalpercentageofCPUusedbyallqueryexecutorprocessesonahostworkingonthesamequery.

Notethatthisruleestablishesarangebetween20%and30%CPUutilization.ThrottlingonahostbeginswhentotalCPUutilizationforthequeryexceeds20%andendswhenitdropsbelow20%.ThrottlingkeepstheCPUutilizationfromexceeding30%.Setting max_cpu argumenthigherthantherule’striggerthresholdpreventsrapidlyalternatingbetweenthrottlingenabledandthrottlingdisabledstatesthatcouldoccurifthethresholdandmaximumCPUareequal.

pg_cancel_backendThe host:pg_cancel_backend actioncancelsaqueryonahost.Itexecutesthe pg_cancel_backend() PostgreSQLfunctiononthesessionmatchedbytheconditionexpression.

Thefollowingrulecancelsthecurrentqueryinasessionthatexceeds75%totalCPUutilizationonanysegmenthostandhasrunformorethanfiveminutes:

©CopyrightPivotalSoftwareInc,2013-2017 14 1.7.0

Page 15: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

host:pg_cancel_backend()whensession_id:host:total_cpu>75andsession_id:host:pid:runtime>300

Whenarulecancelsaquery,WorkloadManagerlogstheeventinalogfileonthesegmenthost.Theseeventrecordscanbequeriedusingthegp_wlm_events databaseview.TheviewdependsonGreenplumexternaltablesoneachsegmenthostandmustfirstbesetupusing manage-event-tables.sh

script.SeeQueryingWorkloadManagerEventDatafordetails.

pg_terminate_backendThe pg_terminate_backend actionexecutesthePostgreSQL pg_terminate_backend() functiononthesessionmatchedbytheconditionexpression.Thisisanunscopedactionbecauseasessionmustbeterminatedonallsegments.

Thefollowingruleterminatesasessionthatexceeds75%totalCPUutilizationonanysegmenthostandhasrunformorethanfiveminutes:

pg_terminate_backend()whensession_id:host:total_cpu>75andsession_id:host:pid:runtime>300

Whenaruleterminatesaquery,WorkloadManagerlogstheeventinalogfileoneachsegmenthost.Theseeventrecordscanbequeriedusingthegp_wlm_events databaseview.TheviewdependsonGreenplumexternaltablesoneachsegmenthostandmustfirstbesetupusing manage-event-tables.sh

script.SeeQueryingWorkloadManagerEventData fordetails.

ConditionExpressionTheconditionexpression(predicate)ofaruleisaBooleanexpressionthatidentifiesGreenplumDatabasequeriesyouwanttoactupon.

Datumscanbecomparedtovaluesusingthefollowingoperators.

Operator ValueFormat Description

=Anumberfornumericdatumsoraquotedstringforstrings.

Matchesonlywhenthevaluesareexactlyequal.

!=Anumberfornumericdatumsoraquotedstringforstrings. Matcheswhenthevaluesarenotequal.

=~Regularexpressionontherightsideenclosedinslashes( / ). datum =~ /sel.*by/

Performsaregularexpressionmatchbetweenthestringvalueandthespecifiedregex.Posixregularexpressionsyntaxisused.

> Number Greaterthan

< Number Lessthan

>= Number Greaterthanorequalto

<= Number Lessthanorequalto

Expressionscanbearbitrarilycomplex,joiningmultiplecomparisonswithBooleanANDandORoperatorsandparenthesestoenforceprecedence.Forexample:

host:pid:cpu_util>50or(host:pid:cpu_util>30andsession_id:host:pid:usename="fred")

IncludingClauseThe including keywordintroducesacomma-separatedlistofdatumstoaddtothecontextwhenaruletriggers.Anydatumreferencedintheconditionexpressionisautomaticallyaddedtothecontext.Toaddcontextvaluesfordatumsnotusedintheconditionexpression,listthedatumsaftertheincluding keyword.

Datumsinthe including clausearespecifiedwithoutscopes.Iftherulescompilercannotinferthescopefromscopesalreadyboundintherule,therulefailscompilationwithanerrormessage.

Thefollowingruleaddsthe host:pid:long_name and host:pid:avg_cpu_util datumstothecontext:

gpdb_record(message="CPUover50%")whenhost:pid:cpu_util>50includinglong_name,avg_cpu_util

©CopyrightPivotalSoftwareInc,2013-2017 15 1.7.0

Page 16: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

The host:pid:cpu_util datumisinthecontextbecauseitisreferencedintheconditionclause.

Whena gpdb_record actiontriggers,thecontextdatumsareaddedtothe context_args columnofthe gp_wlm_events table.Whena host:pg_cancel_backend orpg_terminate_backend actiontriggers,thecontextdatumsareaddedtothe context columnofthe gp_wlm_events view.

Theadditionaldatumvaluescanprovideusefulinformationwheninvestigatingrecordedmessagesandterminationevents.

DatumsandScopesDatumsaredataitemscollectedbytheagent,andincludeoperatingsystemstatistics,OSprocessstatistics,anddatabasequerydata.

WorkloadManagerprovidesarichsetofdatumstouseinconditionexpressionssothatyoucantargetqueriesandqueryprocesseswithveryspecificcharacteristics.Forexample,arulecouldtargetqueriesexecutedwithacertaindatabaserolethataccessacertaintableanduseover30%ofCPUonanyhost.

Thenameofadatumisprefixedbyitsscope,whichprovidescontextforthedatum.Thehost:pid scopeofthe host:pid:cpu_util datum,forexample,meansthatthe cpu_util datumisthepercentageofCPUusedbyanOSprocess( pid )executingonaspecifichost( host ).The session_id:host:pid scopeforthesession_id:host:pid:usename datumindicatesthatthe usename datumisthedatabaseroleexecutingaGreenplumDatabasesegmentqueryprocess.Thesession_id istheidofthequeryand host isthesegmenthostwherethequeryexecutorprocess, pid ,isexecuting.

Datumsinthe including listofarulearespecifiedwithoutscopes.Therulescompilersearchesforincludeddatumsinscopesalreadyboundintheconditionexpressionandfailsifthescopecannotbeinferred.

Rulesmustbewritteninawaytoidentifyasinglequeryexecutorprocessonahost.Thefollowingrulerecordsamessagewhentheresidentmemorysizeforanyprocessexceeds20%.The host:pid scopedoesnotincludea session_id ,soanadditionalrexexptermisaddedtotheconditionexpressionmatchanyquery.Thisensuresthatthe host:pid:resident_size_pct datumisfromaqueryexecutorprocessandthattheactionhasaknownquerywhenitexecutes.Withoutthe session_id:host:pid:usename comparison,thisrulewouldfailtocompile.

ruleaddmem_high_segment_useage_20gpdb_record(message="MEM:highsegmentpctusage-20%")whenhost:pid:resident_size_pct>20andsession_id:host:pid:usename=~/.*/

WorkloadManagerDatumReferencelistsallofthedatums,theirscopes,andtheirdataformats.

datid ScopeThe datid scopeisfordatumsthatarevaluesfromasingledatabaseintheGreenplumDatabasesystem.Thedatid:datname datum,forexample,canbeusedtorestrictaruletoaspecificdatabase:

...anddataid:datname='my_db'

Datumswith datid scopemustbecombinedintheconditionexpressionwithotherdatumsthatidentifyaqueryprocess.

gpdb ScopeThe gpdb scopeisfordatumsfromtheentireGreenplumDatabasesystem.Thereiscurrentlyjustonesuchdatum:gpdb:total_master_connections ,whichisthetotalnumberofclientconnectsforalldatabasesinthesystem.Thisdatumcouldbeusedtopreventarulefromtriggeringuntilaspecifiednumberofconnectionsisexceeded.

host ScopeThe host scopeappliestodatumsthatarevaluesfromasinglehostintheGreenplumcluster.Theseincludethecurrentdateandtimevaluesfromthehostandthehost’stotalCPUutilization.

host:segment_id ScopeThe host:segment_id ScopeisusedfordatumsfromasingleGreenplumsegment.Itisusedfordatumsthatreportthevirtualmemory(vmem)usageforasegment.

host:pid ScopeThe host:pid scopeisfordatumsreferringtoanyoperatingsystemprocessonahost.Thesedatumsincludethememory,CPU,andI/OstatisticsavailablefromLinuxforOSprocesses.Datumswith host:pid scopecanbeusedtonarrowaruletoqueryprocessesusingmorehostresourcesthanexpected.

session_id ScopeA session_id istheGreenplumcluster-wideIDforadatabasequery.Thedatumswith session_id scopeareCPUanddiskI/OskewstatisticsforasinglequerythatWorkloadManagercalculatesfromthe host:pid datumsfromallqueryexecutorprocessesonallsegmenthostsforthe

©CopyrightPivotalSoftwareInc,2013-2017 16 1.7.0

Page 17: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

query.

session_id:host ScopeThe session_id:host scopeincludesdatumsthatareaggregatedmemory,CPU,andI/Ostatisticsforallprocessesonallhostsrunningaquery.

session_id:host:segment_id ScopeThe session_id:host:segment_id scopeincludesdatumsthatreporttheamountofvirtualmemory(vmem)consumedbyaGreenplumsegmentforasession.

session_id:host:pid ScopeThe session_id:host:pid scopeisusedfordatumsthattakevaluesfromaqueryexecutorprocessonasinglesegmenthost.

©CopyrightPivotalSoftwareInc,2013-2017 17 1.7.0

Page 18: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

AddingRules

AddRuleCommandSyntaxThe ruleadd commandaddsarule.Hereisthesyntaxfortheruleaddcommand:

ruleadd[transient]<name><action-name>(<action-args>)when<expression>[including<datum_list>]

transientRulesmaybepersistentortransient.Apersistentruleremainsactiveuntilitisdeleted,whileatransientruledisappearswhentherulesengineserviceisshutdownonallhosts.Rulesarepersistentbydefault;youmustincludethe transient keywordtocreateatransientrule.

<name>Auniquenamefortherule.Thename all isreserved.

<action-name>Theactiontoperform.Oneofthefollowing:

host:throttle_gpdb_query –specifyamaximumallowedCPUutilizationpercentageforaGreenplumDatabasequery.

host:pg_cancel_backend -cancelthecurrentqueryonahostbycallingthePostgreSQLhost:pg_cancel_backend() function.

pg_terminate_backend –terminateasessionbycallingthePostgreSQL pg_terminate_backend() function.

gpdb_record –recordaneventaboutaqueryinthe gp_wlm_records table.

<action-args>Argumentsthatpassvaluestotheaction,ifneeded.Anargumentisspecifiedasan arg-name=value pair.Multipleargumentsareseparatedbycommas.

<expression>ABooleanexpressionthatfilterstargetsfortheaction.Theexpressionreferencesoneormoredatumstofilterthefactsthattriggertheaction.TheexpressionmaycontainPosixregularexpressions(regex).

including<datum-list>Anoptional,comma-separatedlistofdatumstoaddtothecontextwhentheruletriggers.Withoutan including clause,theactioncontextcontainsonlyvaluesfordatumsreferencedinthe expression clause.Addthe including clausetoaddvaluesforadditionaldatumstotheactioncontext.

Datumsinthe<datum_list>arespecifiedwithoutscopeprefixes.IftheWorkloadManagerrulecompilercannotfindadatuminanycurrentlyboundscope,addingtherulefailswithanerrormessage.

When gpdb_record , host:pg_cancel_backend ,and pg_terminate_backend actionsaretriggered,thedatumsin<datum-list>areaddedtothecontextargumentscolumnsinthe gp_wlm_records tableor gp_wlm_events view.

RuleActions

host:throttle_gpdb_queryThrottleaGreenplumDatabasequeryonaspecifiedhost.

Arguments:

max_cpu -HoldprocesstoamaximumofthispercentageCPUutilization.

pid -Theprocesstothrottle.

session_id -Thesessiontothrottle.

The max_cpu argumentisrequired.The pid and session_id argumentscanbeinferredfromthesession_idinthewhenclauseandarenormallyomitted.

©CopyrightPivotalSoftwareInc,2013-2017 18 1.7.0

Page 19: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

host:pg_cancel_backendCancelaqueryonahost.ThisactioncallsthePostgreSQLpg_cancel_backend administrativefunction.

Arguments:

session_id –ThesessionIDofthequerytoterminate.

Theargumentisnormallyomitted,allowingthesessionIDtobeinferredbyusingthesession_idintherule’swhenclause.WorkloadManagerthendetermineswhichsessiontocancel.TheactionsendsaSIGINTsignaltothesessionprocess,whichcancelsthecurrentquery.Seehttp://www.postgresql.org/docs/9.3/static/functions-admin.html formoredetails.

Thefollowingexamplecancelsthecurrentqueryinanysessionthathasbeenexecutingformorethan20seconds:

mdw/gpdb-cluster>ruleaddcancel_queryhost:pg_cancel_backend()whensession_id:host:pid:runtime>20

pg_terminate_backendTerminateasessiononallhosts.ThisactioncallsthePostgreSQLpg_terminate_backend administrativefunction.

Arguments:

session_id –ThesessionIDtoterminate.

Theargumentisnormallyomitted,allowingthesessionIDtobeinferredbyusingthesession_idmatchedbyrule’swhenclause.WorkloadManagerthendetermineswhichpidtoterminate.Seehttp://www.postgresql.org/docs/9.3/static/functions-admin.html formoredetails.

Thefollowingexampleterminatesanysessionthathasbeenexecutingformorethan20seconds:

mdw/gpdb-cluster>ruleaddcancel_sessionpg_terminate_backend()whensession_id:host:pid:runtime>20

gpdb_recordLogsamessagetothe gp_wlm_records tablewhenaruleismatched.

Arguments:

current_query -Thetextofthecurrentquery

gpdb_segment_role -Roleofthedatabaseinstance: GPDB_MASTER or GPDB_SEGMENT

host -Thehostnameofthesegment

message –Informativestringdescribingthereasonforrecording.

pid -Thepostgresprocessassociatedwiththequery

query_start -Querystarttime

session_id -Sessionidofthequery

usename -Nameoftheuserloggedintothisbackend

Onlythemessageargumentmustbesupplied;allotherargumentscanbeinferredfromtherule’swhenclause.

Thefollowingexamplelogsallqueries:

mdw/gpdb_cluster>ruleaddrecord_querygpdb_record(message="all")whensession_id:host:pid:usename=~/.*/

SeeQueryingthegp_wlm_recordsTable forinformationaboutthe gp_wlm_records table.

©CopyrightPivotalSoftwareInc,2013-2017 19 1.7.0

Page 20: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

ManagingRulesUsingcommandsdescribedinthistopic,rulescanbedisplayed,deleted,modified,andsavedtoorrestoredfromdisk.Eachofthecommandshasagp-wlm command-lineequivalent.

DisplayingRulesUsethe rule

showcommandtoseeexistingrules.Youcanshowallexistingrulesorspecifyasinglerulebyname.

ruleshow{all|rule-name}

The ruleshowall

commandinthisexamplelistsallregisteredrules:

mdw/gpdb-cluster>ruleshowall---Name--------------Expression-----------record_querygpdb_record(message="all")whensession_id:host:pid:usename=~/.*/cancel_querypg_terminate_backend()whensession_id:host:pid:runtime>20throttle_queryhost:throttle_gpdb_query(max_cpu=20)whensession_id:host:pid:current_query=~/.*selectcount.*/

Thisexamplelistsasinglerulebyname:

mdw/gpdb-cluster>ruleshowthrottle_query---Name--------------Expression-----------throttle_queryhost:throttle_gpdb_query(max_cpu=20)whensession_id:host:pid:current_query=~/.*selectcount.*/

DeletingRulesTheruledeletecommandremovesarule.

ruledeleterule-name

Todeleteallrulesatonce,use ruledeleteall :

ruledeleteall

Iftherearenorules,thiscommandreturnsanerror.

ModifyingaRuleUsethe rulemodify commandtoaltertheexpressionforanexistingrule.Youmayalsoremovethetransientkeywordfromtheruledeclarationtoconvertittoapersistentrule.Conversionfrompersistenttotransientisnotcurrentlysupported.

rulemodify[transient]nameaction-name(action-args)whenexpression

Thisexamplemodifiesthe cancel_query ruletoalterthenumberofsecondsaqueryrunsonahosttotriggertherulefrom20to25:

mdw/gpdb-cluster>rulemodifycancel_querypg_terminate_backend()whensession_id:host:pid:runtime>25

SavingRulestoDiskThe ruledump commandsavesallpersistentrulesintheclustertoatextfile,oneruleperline.

©CopyrightPivotalSoftwareInc,2013-2017 20 1.7.0

Page 21: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

ruledumppath

Ifyoudonotprovidethefullpathtothefile,thefileiswrittenrelativetothedirectorywhereyoustartedthe gp-wlm session.Theuserrunning gp-wlmmusthavepermissiontowritethefileatthespecifiedlocation.Ifthefileexists,the ruledump commandoverwritesit.

Thefollowingexamplesavesrulestothe /home/gpadmin/rules/20150910-1 file.Ifthe /home/gpadmin/rules directorydoesnotexist,anerrorisreported.

mdw/gpdb-cluster>ruledump/home/gpadmin/rules/20150910-1

ImportingRulesfromDiskThe ruleimport commandimportsrulesfromafileintotheactivesetofrules.Importedrulesreplaceexistingruleswiththesamenames.Existingruleswithnamesnotpresentinthefileareunchanged.

ruleimportpath

RestoringRulesfromDiskThe rule

restorecommandrestoresallrulesfromafile,replacinganyexistingrules.Itisequivalentto rule

delete=allfollowedby ruleimport

path.

rulerestorepath

©CopyrightPivotalSoftwareInc,2013-2017 21 1.7.0

Page 22: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

ExampleRulesThissectionprovidesexamplesofruleswrittenforvariouspurposes.

Note:Rulesmustbeenteredonasingleline,buttherulesshowninthissectionarewrappedforreadability.

RecordhighcpuutilizationqueriesThefollowingruleinvokesthe gpdb_record actionwhenthegpadminuserrunsaqueryanditstotalcpuutilizationonahostexceeds100%.

ruleaddsimplegpdb_record(message="Toomuchcpuforgpadmin")whensession_id:host:total_cpu>100andsession_id:host:pid:usename='gpadmin'

ThrottlethecpuutilizationofaqueryThisruleinvokesthe host:throttle_gpdb_query actionwhenthecpuutilizationofaprocessexceedsathresholdandthequeryhasrunformorethan20seconds.

ruleaddthrottlehost:throttle_gpdb_query(max_cpu=30)whenhost:pid:cpu_util>20andsession_id:host:pid:usename='gpadmin'andsession_id:host:pid:runtime>20

Cancelanyquerywherethesessionhasrunlongerthan120secondsThisruleinvokesthe host:pg_cancel_backend actionwhena session_id:host:pid:runtime exceedstwominutes.

ruleaddkill_longhost:pg_cancel_backend()whensession_id:host:pid:runtime>120

ThrottleandevenoutskewThisruleinvokes host:throttle_gpdb_query whenthetotalcpuusageofaqueryonahostexceeds90%andthecurrentqueryisaselectontheskewtesttable.

ruleaddskewrulehost:throttle_gpdb_query(max_cpu=50)whensession_id:host:total_cpu>100andsession_id:host:pid:current_query=~/select.*skewtest/

Youcanobservetheeffectsofthisruleinthe gptop GPDBSkewpage.

ComplexruleThisruleinvokes gpdb_record foraquerythatmeetsthefollowingcriteria:

aqueryhastotalCPUusagegreaterthan90%onahostandhasbeenrunningformorethan45seconds,or

hascpuskewgreaterthan20%,and

isaselectonatablethatcontains“test”initsname.

ruleaddcomborulegpdb_record(message="MyMessage")when((session_id:host:total_cpu>90andsession_id:host:pid:runtime>45)orsession_id:cpu_skew>20)andsession_id:host:pid:current_query=~/select.*test/

©CopyrightPivotalSoftwareInc,2013-2017 22 1.7.0

Page 23: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

TheruleshowshowyoucangroupBooleanexpressionswithparentheses.

RecordquerieswithhighmemoryusageThisrulerecordsamessagewhenaqueryprocessexceeds20%oftheresidentmemoryonahost.

ruleaddtransientmem_high_segment_useage_20gpdb_record(message=”MEM:highsegmentpctusage-20%”)whenhost:pid:resident_size_pct>20andsession_id:host:pid:usename=~/.*/

Recordquerieswithmemory(rss)skewabove10%Thisrulecallsthe gpdb_record actiontologwhenmemoryskewexceeds10%onahost.

ruleaddmem_skew_10gpdb_record(message="MEM:queryskew10")whensession_id:resident_size_pct_skew>10andsession_id:host:pid:usename=~/.*/

©CopyrightPivotalSoftwareInc,2013-2017 23 1.7.0

Page 24: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

BestPracticesforRules1. Avoidcreatingrulesthatmodifytheconditiontherule’sexpressionismatching.Forexample,considerthisrule:

host:throttle_gpdb_query(max_cpu=20)whenhost:pid:cpu_util>30andsession_id:host:pid:runtim>0

IfCPUusagegoesabove30%,theruletriggersandreducestheusageto20%.Whentheusagefallsbelow30%,theruleisnolongermatched,sothethrottlingendsandusagecanagainclimbto30%.Thiscreatesanundesirablecyclicbehavior.Instead,createarulelikethefollowing:

host:throttle_gpdb_query(max_cpu=30)whenhost:pid:cpu_util>20andsession_id:host:pid:runtime>0

Thisruletriggersat20%CPUutilizationandthrottlestheCPUto30%utilization.Thethrottlingcontinuesuntilutilizationdropsbelow20%.Thesession_id:host:pid:runtime conditionistrueforanyrunningqueryandprovidesthenecessary session_id forthe throttle_gpdb_query action.

2. Avoidcreatingrulesthatterminateaquerybasedonskewalone.Considerthefollowingrule:

pg_terminate_backendwhensession_id:resident_size_pct_skew>10

Thisisapoorrulefortworeasons.First,itterminatesallquerieswhenskewisabove10,includingqueriesthatwerenotcontributingtoskew.Second,wellbehavedqueriescantemporarilyexperienceskewhighenoughtoachievethiscondition.Forexample,ifthesegmentsdonotcompleteaqueryatthesametime,skewcanappearneartheendofexecution.Aquerycouldrunnormallyacrossseveralnodesandthen,aseachnodecompletesitsportionofthequery,itsresourceutilizationdrops,causingatemporaryincreaseinskewwhileothernodesarestillrunning.

3. Rulesthatmatchdatawith datid: scopewilltriggerforanydatabaseintheclusterunlessapredicateisaddedtoconfinethematchtoatargetdatabase.Forexample,thisruletriggerswheneverthenumberofconnectionstoanysingledatabaseexceeds10:

gpdb_record(message="exceeded10connections")whensession_id:host:pid:runtime>0anddatid:numbackends>10

Addapredicatetofilterforthedatabaseassociatedwiththesession:

gpdb_record(message="exceeded10connectionsonfoo")whensession_id:host:pid:runtime>0anddatid:datname="foo"anddatid:numbackends>10

©CopyrightPivotalSoftwareInc,2013-2017 24 1.7.0

Page 25: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

KnownIssuesTowritearulethatperformsaGreenplumDatabaseaction( gpdb_record , pg_terminate_backend , host:throttle_gpdb_query ),theconditionmustincludeasession_id ,evenwhentheintendedconditionisbasedsolelyonprocessinformation.Forexample,thefollowingruleappearstoterminateanyquerythatusesmorethan20%ofsystemmemory:

pg_terminate_backend()whenhost:pid:resident_size_pct>20

However,becausethisrulecontainsno session_id ,WorkloadManagercannotinferthequerytoterminate,andtherulewillnotbeadded.Togetthedesiredbehavior,addanalways-true session_id conditiontotherule,forexample:

pg_terminate_backend()whenhost:pid:program_size_pct>20andsession_id:host:pid:runtime>0

©CopyrightPivotalSoftwareInc,2013-2017 25 1.7.0

Page 26: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

QueryingWorkloadManagerRecordDataThe gp_wlm_records tablecontainsarecordofeventsdescribingwhere,why,andhowthe gpdb_record actionwastriggeredbyaruleontheGreenplumcluster.

The gp_wlm_records tableiscreatedinthe postgres databasebydefault.Adifferentdatabasecanbespecifiedatinstallationtimewithwiththe--dbname-records installationoption.

Thetablehasthefollowingstructure:

Column Type

time text

state text

ident text

hostname text

query_start text

message text

pid integer

session_id integer

gpdb_segment_role text

usename text

current_query text

rule text

context_args text

Theprimaryidentifierofeachentryinthetableisthe ident column.Thiscolumnstoresauniqueidentifierthatrepresentsaspecificrulethattriggeredonaspecificnodeinthecluster.Ifaruletriggersonmorethanonenodeintheclusteratthesametime,eachnodeistreatedasaseparateeventandreceivesauniqueidentifier.

Followingaretwosampleentriesfromthe gp_wlm_records table.Inthisexample,arulewascreatedtotrackwhenaqueryrunsformorethan120seconds:

=#\xonExpandeddisplayison.=#select*fromgp_wlm_records;-[RECORD1]-----+-----------------------------------------------------------------------------------------time|FriJun1714:30:272016state|BEGINident|36b3369d-0be8-4d98-b116-6d55f1caf122hostname|sdw2query_start|2016-06-1714:28:24.162044-07message|Queryexceeds120seconds.pid|98885session_id|1112gpdb_segment_role|GPDB_SEGMENTusename|gpadmincurrent_query|deletefromtestwheref1();rule|gpdb_record(message="Queryexceeds120seconds.")whensession_id:host:pid:runtime>120context_args|runtime=121-[RECORD2]-----+-----------------------------------------------------------------------------------------time|FriJun1714:31:072016state|ENDident|36b3369d-0be8-4d98-b116-6d55f1caf122hostname|query_start|message|pid|session_id|gpdb_segment_role|usename|current_query|rule|context_args|

Intheaboveexample,the state columnrepresentswhenaquerybegantriggeringaruleonagivennodeandwhenitstopped.Thehostname columnstoresthehostonwhichtheruletriggered.

©CopyrightPivotalSoftwareInc,2013-2017 26 1.7.0

Page 27: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

©CopyrightPivotalSoftwareInc,2013-2017 27 1.7.0

Page 28: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

QueryingWorkloadManagerEventDataWhenaWorkloadManagerrulesuccessfullyexecutesa pg_terminate_backend() or host:pg_cancel_backend() actiontocancelaGreenplumDatabasequery,theeventisloggedtoafileonthehost.

The manage-event-tables.sh utilityscriptcreatesexternaltablestoaccessthelogfilesandaviewtoconsolidatetheexternaltablessothatyoucanquerytheseeventrecordsfromwithinadatabase.Theexternaltablesandviewmustfirstbecreatedusingthe manage-event-tables.sh script.Theexternaltablesarecreatedinthepostgresdatabasebydefault,butyoucanspecifyadifferentdatabasewhenyoucreatethetables.

SettingUpthegp_wlm_eventsViewThe manage-event-tables.sh scriptcreates,recreates,ordropstheexternaltablesand gp_wlm_events view.

Toseethesyntax,logintotheGreenplummasterhostasthegpadminuserandrunthescriptwiththe -h ( --help )option:

$<INSTALL_DIR>/bin/manage-event-tables.sh--helpManagethegp-wlmexternaleventtables.Commands:--createCreatetheexternaltableandviews.--dropDroptheexternaltableandviews.-h,--helpDisplaythismessage.Options:-d,--dbname=NAMEUsedatabaseNAME.Defaultispostgres.-q,--quietSilencestdout.

Tocreate(orrecreate)theexternaltablesandthe gp_wlm_events view,runthescriptwiththe --create flag.Ifyouwanttocreatethetablesandviewinadatabaseotherthanpostgres,includethe --dbname option.

<INSTALL_DIR>/bin/manage-event-tables.sh--create--dbname=<database-name>

Todeletethetablesandviewsfromadatabaseotherthanpostgres,youmustincludethe --dbname optionwiththe --drop option.

Usingthegp_wlm_eventsViewThe gp_terminate_backend and pg_cancel_backend eventsareloggedandaccessibleinthe pg_wlm_events view.

Thefollowingtabledescribesthecontentsofthe gp_wlm_events view.

Columnname Type Description

ident text Auniqueidentifierforeachrow.

time timestamp Thetimetheeventrecordwascreated.

rulename text Thenameofthetriggeredrule.

action text Thecomponentthattriggeredtheevent.

sess_id integer TheIDofthesessionthatmatchedthisruletrigger.

hostname text Thehostonwhichtheeventoccurred.

usename text Therolenamefromthesessionthatmatchedthisruletrigger.

current_query text Thetextofthecurrentqueryinthesession.

datname text Thedatabasenameofthesession.

application_name text Thenameoftheclientapplicationofthesessionthatmatchedthisruletrigger.

context text Acomma-delimitedlistofrule-specificcontextualdatums.

rule text Theruleexpression.

The sess_id , usename , current_query , datname ,and application_name columnsmatchcolumnswiththesamenamesinthe pg_stat_activity systemviewrowfortheprocessthatmatchedtheruletrigger.Seepg_stat_activity .

Sincetheviewisbasedonexternaltables,eachtimeyourunaquery,theviewisrefreshedfromtheeventlogsontheGreenplumhosts.

©CopyrightPivotalSoftwareInc,2013-2017 28 1.7.0

Page 29: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

Followingisanexampleof pg_cancel_backend and pg_terminate_backend rowsinthe gp_wlm_events view:

postgres=#select*fromgp_wlm_events;-[RECORD1]----+--------------------------------------------------------------------------------ident|e7054d71-293b-4bce-a3bb-caafbcbc6758time|2017-01-3119:31:02rulename|testaction|pg_cancel_backendsess_id|4200hostname|localhost.localdomainusename|pivotalcurrent_query|selectpg_sleep(10);datname|postgresapplication_name|psqlcontext|runtime=6,host=localhost.localdomain,session_id=4200,host=localhost.localdomainrule|host:pg_cancel_backend()whensession_id:host:pid:runtime>3-[RECORD2]----+--------------------------------------------------------------------------------ident|0c1f50dd-e1fc-4dd8-9829-7e450f74fde8time|2017-01-3119:37:30rulename|test2action|pg_terminate_backendsess_id|4226hostname|localhost.localdomainusename|pivotalcurrent_query|<IDLE>datname|postgresapplication_name|psqlcontext|runtime=8,session_id=4226rule|pg_terminate_backend()whensession_id:host:pid:runtime>3

©CopyrightPivotalSoftwareInc,2013-2017 29 1.7.0

Page 30: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

ManagingResourceQueuesUse rq commandstoshow,create,remove,andmodifyresourcequeues,andtomanagetherolesthatareassignedtoresourcequeues.

The queue-settings argumentcancontainthefollowingproperties:

PropertyName Type Description

active_statements IntegerLimitsthenumberofqueriesthatcanbeexecutedbyrolesassignedtotheresourcequeue.Eithertheactive_statements or max_cost propertymustbesetoneachresourcequeue.

max_cost FloatSetsamaximumlimitonthetotalcostofqueriesthatcanbeexecutedbyrolesassignedtotheresourcequeue.Thecostofaqueryisestimatedbythequeryplannerandismeasuredinunitsofdiskpagefetches.Eitherthe active_statements or max_cost propertymustbesetoneachresourcequeue.

min_cost FloatSetstheminimumestimatedquerycostforaquerytobemanagedbytheresourcequeue.Querieswithestimatedcostsbelowthisthresholdareexecutedimmediately.

cost_overcommit BooleanIfaresourcequeueislimitedbasedon MAX_COST ,aquerythatexceedsthe MAX_COST limitisallowedtoexecuteifthesystemisidleand COST_OVERCOMMIT is true .If COST_OVERCOMMIT issetto false ,queriesthatexceed MAX_COST arealwaysrejected.

priority EnumerationSetstherelativepriorityofqueriesexecutedbyrolesassignedtotheresourcequeue.Theallowedvalues,inorderofincreasingpriority,are MIN , LOW , MEDIUM , HIGH ,and MAX .

memory_limitInteger(kilobytes)

Setsthetotalamountofmemorythatallactivestatementssubmittedtothequeuemayconsume.Theminimumis10240KB.Thereisnomaximum,butwhenaqueryexecutesitislimitedbythesegmenthost’sphysicalmemory.Settheparameterto-1fornolimit.

:Table1.ResourceQueueProperties

Specifytheresourcequeuepropertiesina parameter-name=value format,forexample:

mdw/gpdb-cluster>rqmodifymyrqwithactive_statements=10

Separatemultiplequeuesettingswithacomma.The queue-settings argumentmustnotcontainspaces.Thisexamplesetsthreeproperties:

mdw/gpdb-cluster>rqaddETLwithactive_statements=3,priority=LOW,memory_limit=524288

AGreenplumDatabaserole(loginuser)isassociatedwithasingleresourcequeue.Newlycreatedrolesareaddedtothe pg_default queueifanotherresourcequeueisnotspecified.

Queriessubmittedbyusersassociatedwitharesourcequeuearemanagedbythequeue.Thequeue’ssettingsdeterminewhetherqueriesareacceptedorrejected,iftheyrunimmediatelyorwaitforresourcestobereturnedtothequeue,howmuchmemorytoallocatetothequery,andtherelativeamountofCPUthequerywillhave.

Resourcequeuessharethememoryallocatedtoeachsegment.Addinganewresourcequeueoralteringaqueue’ssettingsmayrequireadjustingotherresourcequeuestoavoidover-allocatingtheavailablememoryandcausingqueriestofail.SeetheWorkloadManagementsectionintheGreenplumDatabaseAdministratorGuideforguidelinesonconfiguringresourcequeues.

AddingaNewResourceQueue

DeletingaResourceQueue

ModifyingaResourceQueue

DisplayingResourceQueues

AddingUserstoResourceQueues

DeletingaUserfromaResourceQueue

AddingaNewResourceQueueThe rqadd commandcreatesanewresourcequeue.Thecommandhasthefollowingsyntax:

©CopyrightPivotalSoftwareInc,2013-2017 30 1.7.0

Page 31: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

rqaddqueue-namewithqueue-settings

Youmustsetoneorbothofthethresholdproperties— active_statements or max_cost —whenyoucreateanewresourcequeue.

ThefollowingexamplecreatesanETLqueuethatcanrunthreeconcurrentqueriesatlowCPUpriorityrelativetootherqueries.

mdw/gpdb-cluster>rqaddetlwithactive_statements=3,priority=low

DeletingaResourceQueueDeleteanexistingresourcequeuebynameusingthe rqdelete command:

rqdeletequeue-name

Itisnotpossibletodeleteaqueuethathasrolesassignedtoit.

ModifyingaResourceQueueUsethe rqmodify commandtoalterqueuesettings.Youcanaddnewsettingsorupdateexistingsettingsbyspecifyingpropertiesinthe queue-settingsargument.

rqmodifyqueue-namewithqueue-settings

ThefollowingexamplemodifiestheETLqueuetoruntwoconcurrentquerieswithamaximumof524288KB(512MB)ofmemory.Eachquerywillbeallocated256MBofmemory.

rqmodifyetlwithactive_statements=2,memory_limit=524288

DisplayingResourceQueuesUsethe rqshow

allcommandtodisplayresourcequeues.Thisexampledisplayssettingsforthe etl and pg_default resourcequeues.

mdw/gpdb-cluster>rqshowallrsqnameresnameressettingrestypeidetlactive_statements21etlmax_cost-12etlmin_cost03etlcost_overcommit14etlprioritylow5etlmemory_limit5242886pg_defaultactive_statements101pg_defaultmax_cost-12pg_defaultmin_cost03pg_defaultcost_overcommit04pg_defaultprioritymedium5pg_defaultmemory_limit-16

AddingUserstoResourceQueuesThe rq

useraddcommandaddsausertoaresourcequeue.Theuserisremovedfromtheirpreviousresourcequeueasusersareassociatedwithonlyone

resourcequeue.Theuser’ssubsequentqueriesaremanagedbythenewresourcequeue.

rquseraddusertoqueue-name

©CopyrightPivotalSoftwareInc,2013-2017 31 1.7.0

Page 32: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

DeletingaUserfromaResourceQueueThe rquserdel commanddeletesarolefromaresourcequeue.Theuserwillbeassociatedwiththedefaultqueue, pg_default .

rquserdeluserfromqueue-name

©CopyrightPivotalSoftwareInc,2013-2017 32 1.7.0

Page 33: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

ConfiguringWorkloadManagerComponentsYoucanusetheGreenplumWorkloadManager config commandtoview,override,anddescribecertainWorkloadManagerconfigurationsettings.Theconfig commandmayberuninteractivelyina gp-wlm sessionorinbatchmodeatthecommandline.ThecommandmustberunontheGreenplummasterhost.

SeeUsingtheGreenplumWorkloadManagerCommandLinefor gp-wlm command-linesyntaxandusage.

NoteThe config commandworksonlywithsettingsthatcanbechangedbyusers.

Whenviewing,describing,orsettingthevalueofaconfigurationsetting,youmustspecifyitsWorkloadManagercomponent.Acomponentcanbeanindividualservice,plugin,orcommand-linetoolthatisapartoftheWorkloadManagersystem.

Ininteractivemode,youcandouble-tapthetabcharactertoseewhichcomponentsandsettingsareavailablefortheshow,describe,andmodifycommands.

ViewingConfigurationValuesToviewthecurrentvalueofaconfigurationsettingwhileina gp-wlm session,usethefollowingsyntax:

>configshow<component><setting>

Forexample,thefollowingcommandshowstheloggingleveloftherulesengineservice:

>configshowrulesenginelogging:log_level

Fromthecommandline,usethe --config-show option:

$gp-wlm--config-show='<component><setting>'

Forexample:

$gp-wlm--config-show='rulesenginelogging:log_level'

DescribingConfigurationValuesUsethe describe commandtoseeadescriptionofasettingandconstraintsforthesetting’svalues.

Ina gp-wlm session,thesyntaxis:

>configdescribe<component><setting>

Onthe gp-wlm commandline,usethe config-describe command-lineoption:

$gp-wlm--config-describe='<component><setting>'

Forexample,todescribetheloggingleveloftherulesengineinaninteractive gp-wlm session,usethiscommand:

>configdescriberulesenginelogging:log_level

Theoutputofthecommandlookslikethefollowing:

component:rulesenginesetting:logging:log_leveldescription:Thelogverbosityoftherulesenginedaemonvalidvalues:err,warn,info,debug,trace

©CopyrightPivotalSoftwareInc,2013-2017 33 1.7.0

Page 34: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

Hereisthesamecommandinbatchmodeatthecommandline:

$gp-wlm--config-describe='rulesenginelogging:log_level'

ModifyingConfigurationValuesUsethe configmodify commandtochangethevalueofaWorkloadManagerconfigurationsetting.Changingaconfigurationsettingautomaticallychangesthesettingonallhostsinthecluster.

Inaninteractive gp-wlm session,usethissyntax:

>configmodify<component><setting>=<value>

Atthecommandline,usethe gp-wlm --config-modify option,withthefollowingsyntax:

$gp-wlm--config-modify='<component><setting>=<value>'

Thenewsettingispersisted,andwillbepreservedduringfutureWorkloadManagersoftwareupgrades.

Whenasettingforaserviceismodified,theaffectedserviceisautomaticallyrestartedoneveryhostinthecluster.However,thiscanonlyoccurautomaticallyifthecfgmonserviceisrunningontheGreenplummasteratthetimethesettingischanged.Ifthecfgmonserviceisnotrunning,thesettingisstillupdatedpersistently,butthenewvalueisnotbroadcasttotherestoftheclusteruntilthecfgmonserviceisstarted.Thecfgmonserviceisalwaysrunning,bydefault.

ConfigurableWorkloadManagerSettingsThefollowingtablelistssettingsthatcanbeviewed,described,andconfiguredusingthe config command.

Component Setting Description Type Constraints Default

agent logging:log_level Logverbosityofagent String ValidValues:err,warn,info,debug,trace

info

cfgmon logging:log_level Logverbosityofcfgmon String ValidValues:err,warn,info,debug,trace

info

gpdb_stats collect_frequency HowoftentocollectGPDBstatisticsinformation Float Validrange:0.1-60.0seconds 1.0

publish_frequency HowoftentopublishGPDBstatisticsinformation Float Validrange:0.1-60.0seconds 4.0

publish_idle_sessions PublishinformationaboutidleGreenplumDatabasesessions

Boolean ‘true’or'false’ 'true’

rulesengine engine:rule_frequency Frequencyofruleevaluationinseconds Float Validrange:0.1-60.0seconds 2.0

logging:log_level Logverbosityofrulesengine String ValidValues:err,warn,info,debug,trace

info

systemdata logging:log_level Logverbosityofsystemdataplugin String ValidValues:err,warn,info,debug,trace

info

publish_idle_processes PublishinformationaboutidleGreenplumDatabasesessions

Boolean 'true’or'false’ 'true’

©CopyrightPivotalSoftwareInc,2013-2017 34 1.7.0

Page 35: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

TroubleshootingYoumaycollectalllogsacrosstheclusterusingasinglecommand.Tocreateatarballofalllogsinthecurrentdirectory,invoke:

bin/gather-cluster-logs.sh--symlink<LN>

where LN isthepathtothe gp-wlm symboliclinktotheGreenplumWorkloadManagerinstallationdirectory.

©CopyrightPivotalSoftwareInc,2013-2017 35 1.7.0

Page 36: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

WorkloadManagerDatumReferenceThistopicliststhedatumscollectedbyGreenplumWorkloadManager.ThesedatumscanbeusedinWorkloadManagerrulestoselectfactsthattriggeranaction.Inrules,prefixdatumswiththeirscope,forexample:

host:cpu_util>35

Thiswillmatchanyhostwithgreaterthan35%CPUutilitization.Thefollowingexpressionmatchesasingle postgres processonanyhostusingmorethan35%CPU:

host:pid:cpu_util>35andhost:pid:name='postgres'

Thedatumsarearrangedinthefollowingcategories:

Connections–numberofbackendconnectionsandconnectionstothemaster

Identification–namesofusers,hosts,databases,ports,processes,andsoon

Transactions–informationaboutthecurrenttransaction,querieswithintransactions,andnumbersoftransactionscommittedandrolledbackinthedatabase

Date/Time–dateandtimedatumsforahost

CPU–CPUutilitizationforhosts,processes,andsessions

Memory–memoryutilitizationforprocessesandqueries

Spill–numberofspillfilescreatedandtotalspillfilesizeforaquery

I/O–diskread/writestatisticsfordatabases,processes,andqueries

Skew–diskread/writeskewandmemoryskewforqueries

ConnectionsScope Datum Datatype Description

datid numbackends integer Numberofbackends

gpdb total_master_connections integer Totalnumberofconnectionstothemastersegmentacrossalldatabases

Identification

Scope Datum Datatype Description

session_id:host:pid usename string Nameoftheuserloggedintothisbackend

datid datname string Nameofthisdatabase

host:pid long_name stringBydefault,thisistheabsolutepathtotheprocessexecutable,butmaybeoverriddenbytheprocessitselftostatusinformationinutilitieslikeps(1)

host:pid name string Thefilenameoftheexecutable

host:pid state string Kernelstateofthisprocess;seethemanpageforproc(5)formoreinformation

session_id:host:pid application_name string Nameoftheapplicationthatisconnectedtothisbackend

session_id:host:pid client_addr string IPaddressoftheclientconnectedtothisbackend

session_id:host:pid client_port integer TCPportnumberthattheclientisusingforcommunicationwiththisbackend

session_id:host:pid datid integer OIDofthedatabasethisbackendisconnectedto

session_id:host:pid datname string Nameofthedatabasethisbackendisconnectedto

session_id:host:pid gpdb_segment_role string ThecurrentroleofthisGreenplumDatabasesegment(MASTER,SEGMENT,MIRROR)

session_id:host:pid usesysid integer OIDoftheuserloggedintothisbackend

©CopyrightPivotalSoftwareInc,2013-2017 36 1.7.0

Page 37: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

TransactionsScope Datum Datatype Description

datid xact_commit integer Numberoftransactionsinthisdatabasethathavebeencommitted

datid xact_rollback integer Numberoftransactionsinthisdatabasethathavebeenrolledback

session_id:host:pid backend_start string Timewhenthisprocesswasstarted,i.e.,whentheclientconnectedtotheserver

session_id:host:pid current_query string Textofthisbackend’scurrentquery.

session_id:host:pid query_start string Timewhenthecurrentlyactivequerywasstarted

session_id:host:pid runtime integer Timeelapsedsincethequerystarted

session_id:host:pid xact_start string Timewhenthisprocess’currenttransactionwasstarted

Date/TimeScope Datum Datatype Description

host day integer Dayas0-30

host day_of_week integer Dayas0-6

host day_of_week_string string Mon,Tue,…

host month integer Monthas0-11

host year integer Numericyear

host hour integer Houras0-23

host minute integer Minuteas0-59

CPU

Scope Datum Datatype Description

host node_cpu_util float CurrentCPUutilizationonthishost,normalizedbynumberofactiveCPUs

host:pid avg_cpu_util float AverageCPUutilizationconsumedbythisprocessoverthelasttwopollingintervals

host:pid cpu_util float PercentageoftotalCPUutilizationconsumedbythisprocess

session_id cpu_skew floatCPUutilizationskewacrossthecluster.Calculatedasthecubedstandarddeviationofsession_id:host:total_cpufromallhostsrunningacertainquery

session_id:host total_cpu float Totalcpuutilizationofallprocessesrunningacertainqueryonahost

Memory

Scope Datum Datatype Description

host mem_avail integer Totalavailablememoryonthishost(free+buffers+cached)(kB)

host mem_avail_pct float Availablememoryonthishostaspercentageoftotal

host mem_buffers integer Memoryinbuffersonthishost(kB)

host mem_cached integer Cachedmemoryonthishost(kB)

host mem_free integer Freememoryonthishost(kB)

host mem_free_pct float Freememoryonthishostaspercentageoftotal

host mem_total integer Totalmemoryonthishost(kB)

host:pid data_size_bytes integer Thesizeofdata+stackmemoryregioninthisprocess(bytes)

host:pid dirty_size_bytes integer Thesizeofdirtypagesusedinthisprocess(bytes)

host:pid library_size_bytes integer Thesizeoflibrarymemoryregioninthisprocess(bytes)

©CopyrightPivotalSoftwareInc,2013-2017 37 1.7.0

Page 38: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

host:pid program_size_bytes integer Thetotalprogramsize(bytes)host:pid program_size_pct float Thesizeofthisprocessasapercentageoftotalsystemmemory

host:pid resident_size_bytes integer Thesizeofresidentmemoryconsumedbythisprocess(bytes)

host:pid resident_size_pct float Thesizeofthisprocess’residentmemoryasapercentageoftotalsystemmemory

host:pid shared_size_bytes integer Thesizeofallsharedpagesusedbythisprocess(bytes)

host:pid text_size_bytes integer Thesizeofcodememoryregioninthisprocess(bytes)

host:segment_id total_vmem_size_mb integer TotalvmemusageforthisGreenplumsegmentinmegabytes

host:segment_id total_vmem_size_pct float TotalvmemusageforthisGreenplumsegmentasapercentageoftotal

session_id:host:segment_id vmem_size_mb integer Totalvmemusedbythesessiononthissegment

session_id:host:segment_id vmem_size_pct floatThepercentageofthissegment’s vmem_protect_limit consumedbythissession

session_id:host total_resident_size_pct floatTotalresidentmemorypercentageofallprocessesrunningacertainqueryonahost

Scope Datum Datatype Description

SpillScope Datum Datatype Description

session_id:host:pid spillfile_count_across_cluster integer Totalnumberofspillfilescreatedforthisqueryacrossthecluster

session_id:host:pid spillfile_size_across_cluster integer Totalsizeofspillfilescreatedforthisqueryacrossthecluster

I/OScope Datum Datatype Description

datid blks_hit integer NumberoftimesdiskblockswerefoundalreadyinthePostgreSQLbuffercache

datid blks_read integer Numberofdiskblocksreadinthisdatabase

host:pid disk_read_bytes integer Totalnumberofbytesreadfromdiskbythisprocess

host:pid disk_read_bytes_per_sec float Thenumberofbytesreadfromdiskpersecondbythisprocess

host:pid disk_write_bytes integer Totalnumberofbyteswrittentodiskbythisprocess

host:pid disk_write_bytes_per_sec float Thenumberofbyteswrittentodiskpersecondbythisprocess

host:pid read_bytes integer Totalnumberofbytes(disk,network,IPC)readbythisprocess

host:pid read_bytes_per_sec float Thenumberofbytesreadpersecond(disk+net+IPC)bythisprocess

host:pid reads integer Totalnumberofreadsystemcallsmadebythisprocess

host:pid reads_per_sec float Thenumberoftotalread(2)callspersecondbythisprocess

host:pid write_bytes integer Totalnumberofbytes(disk,network,IPC)writtenbythisprocess

host:pid write_bytes_per_sec float Thenumberofbyteswrittenpersecond(disk+net+IPC)bythisprocess

host:pid writes integer Totalnumberofwritesystemcallsmadebythisprocess

host:pid writes_per_sec float Thenumberoftotalwrite(2)callspersecondbythisprocess

session_id:host total_disk_read_bytes_per_sec integer Totaldiskreadbytes-per-secondofallprocessesrunningacertainqueryonahost

session_id:host total_disk_write_bytes_per_sec integer Totaldiskwritebytes-per-secondofallprocessesrunningacertainqueryonahost

Skew

Scope Datum Datatype Description

session_id disk_read_bytes_per_sec_skew floatDiskreadskewacrossthecluster.Calculatedasthecubedstandarddeviationofsession_id:host:total_disk_read_bytes_per_secfromallhostsrunningacertainquery

session_id disk_write_bytes_per_sec_skew floatDiskwriteskewacrossthecluster.Calculatedasthecubedstandarddeviationofsession_id:host:total_disk_write_bytes_per_secfromallhostsrunningacertainquery

©CopyrightPivotalSoftwareInc,2013-2017 38 1.7.0

Page 39: Table of Contentsgpcc.docs.pivotal.io/pdf/GP-WLM-170-user-guide.pdf · Checking the Health of Greenplum Workload Manager Services At any time, the health of Greenplum Workload Manager

session_id resident_size_pct_skew floatResidentmemoryutilizationskewacrossthecluster.Calculatedasthecubedstandarddeviationofsession_id:host:total_resident_size_pctfromallhostsrunningacertainquery

Scope Datum Datatype Description

©CopyrightPivotalSoftwareInc,2013-2017 39 1.7.0