blob: a1afacee4c5fca48b2730c3318f5e263012583e1 [file] [log] [blame]
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[8142],{3905:(e,t,n)=>{n.d(t,{Zo:()=>u,kt:()=>T});var a=n(7294);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t){if(null==e)return{};var n,a,l=function(e,t){if(null==e)return{};var n,a,l={},s=Object.keys(e);for(a=0;a<s.length;a++)n=s[a],t.indexOf(n)>=0||(l[n]=e[n]);return l}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)n=s[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}var o=a.createContext({}),d=function(e){var t=a.useContext(o),n=t;return e&&(n="function"==typeof e?e(t):r(r({},t),e)),n},u=function(e){var t=d(e.components);return a.createElement(o.Provider,{value:t},e.children)},p="mdxType",m={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},c=a.forwardRef((function(e,t){var n=e.components,l=e.mdxType,s=e.originalType,o=e.parentName,u=i(e,["components","mdxType","originalType","parentName"]),p=d(n),c=l,T=p["".concat(o,".").concat(c)]||p[c]||m[c]||s;return n?a.createElement(T,r(r({ref:t},u),{},{components:n})):a.createElement(T,r({ref:t},u))}));function T(e,t){var n=arguments,l=t&&t.mdxType;if("string"==typeof e||l){var s=n.length,r=new Array(s);r[0]=c;var i={};for(var o in t)hasOwnProperty.call(t,o)&&(i[o]=t[o]);i.originalType=e,i[p]="string"==typeof e?e:l,r[1]=i;for(var d=2;d<s;d++)r[d]=n[d];return a.createElement.apply(null,r)}return a.createElement.apply(null,n)}c.displayName="MDXCreateElement"},4283:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>u,contentTitle:()=>o,default:()=>T,frontMatter:()=>i,metadata:()=>d,toc:()=>p});var a=n(7462),l=n(3366),s=(n(7294),n(3905)),r=["components"],i={id:"tutorial-delete-data",title:"Tutorial: Deleting data",sidebar_label:"Deleting data"},o=void 0,d={unversionedId:"tutorials/tutorial-delete-data",id:"tutorials/tutorial-delete-data",title:"Tutorial: Deleting data",description:"\x3c!--",source:"@site/docs/latest/tutorials/tutorial-delete-data.md",sourceDirName:"tutorials",slug:"/tutorials/tutorial-delete-data",permalink:"/docs/latest/tutorials/tutorial-delete-data",draft:!1,tags:[],version:"current",frontMatter:{id:"tutorial-delete-data",title:"Tutorial: Deleting data",sidebar_label:"Deleting data"},sidebar:"docs",previous:{title:"Compacting segments",permalink:"/docs/latest/tutorials/tutorial-compaction"},next:{title:"Writing an ingestion spec",permalink:"/docs/latest/tutorials/tutorial-ingestion-spec"}},u={},p=[{value:"Load initial data",id:"load-initial-data",level:2},{value:"How to permanently delete data",id:"how-to-permanently-delete-data",level:2},{value:"Disable segments by interval",id:"disable-segments-by-interval",level:2},{value:"Disable segments by segment IDs",id:"disable-segments-by-segment-ids",level:2},{value:"Run a kill task",id:"run-a-kill-task",level:2}],m={toc:p},c="wrapper";function T(e){var t=e.components,i=(0,l.Z)(e,r);return(0,s.kt)(c,(0,a.Z)({},m,i,{components:t,mdxType:"MDXLayout"}),(0,s.kt)("p",null,"This tutorial demonstrates how to delete existing data."),(0,s.kt)("p",null,"For this tutorial, we'll assume you've already downloaded Apache Druid as described in\nthe ",(0,s.kt)("a",{parentName:"p",href:"/docs/latest/tutorials/"},"single-machine quickstart")," and have it running on your local machine."),(0,s.kt)("h2",{id:"load-initial-data"},"Load initial data"),(0,s.kt)("p",null,"In this tutorial, we will use the Wikipedia edits data, with an indexing spec that creates hourly segments. This spec is located at ",(0,s.kt)("inlineCode",{parentName:"p"},"quickstart/tutorial/deletion-index.json"),", and it creates a datasource called ",(0,s.kt)("inlineCode",{parentName:"p"},"deletion-tutorial"),"."),(0,s.kt)("p",null,"Let's load this initial data:"),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-bash"},"bin/post-index-task --file quickstart/tutorial/deletion-index.json --url http://localhost:8081\n")),(0,s.kt)("p",null,"When the load finishes, open ",(0,s.kt)("a",{parentName:"p",href:"http://localhost:8888/unified-console.html#datasources"},"http://localhost:8888/unified-console.md#datasources")," in a browser."),(0,s.kt)("h2",{id:"how-to-permanently-delete-data"},"How to permanently delete data"),(0,s.kt)("p",null,"Permanent deletion of a Druid segment has two steps:"),(0,s.kt)("ol",null,(0,s.kt)("li",{parentName:"ol"},'The segment must first be marked as "unused". This occurs when a user manually disables a segment through the Coordinator API.'),(0,s.kt)("li",{parentName:"ol"},'After segments have been marked as "unused", a Kill Task will delete any "unused" segments from Druid\'s metadata store as well as deep storage.')),(0,s.kt)("p",null,"Let's drop some segments now, by using the coordinator API to drop data by interval and segmentIds."),(0,s.kt)("h2",{id:"disable-segments-by-interval"},"Disable segments by interval"),(0,s.kt)("p",null,"Let's disable segments in a specified interval. This will mark all segments in the interval as \"unused\", but not remove them from deep storage.\nLet's disable segments in interval ",(0,s.kt)("inlineCode",{parentName:"p"},"2015-09-12T18:00:00.000Z/2015-09-12T20:00:00.000Z")," i.e. between hour 18 and 20."),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-bash"},"curl -X 'POST' -H 'Content-Type:application/json' -d '{ \"interval\" : \"2015-09-12T18:00:00.000Z/2015-09-12T20:00:00.000Z\" }' http://localhost:8081/druid/coordinator/v1/datasources/deletion-tutorial/markUnused\n")),(0,s.kt)("p",null,"After that command completes, you should see that the segment for hour 18 and 19 have been disabled:"),(0,s.kt)("p",null,(0,s.kt)("img",{alt:"Segments 2",src:n(325).Z,title:"Segments 2",width:"3342",height:"1504"})),(0,s.kt)("p",null,"Note that the hour 18 and 19 segments are still present in deep storage:"),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-bash"},"$ ls -l1 var/druid/segments/deletion-tutorial/\n2015-09-12T00:00:00.000Z_2015-09-12T01:00:00.000Z\n2015-09-12T01:00:00.000Z_2015-09-12T02:00:00.000Z\n2015-09-12T02:00:00.000Z_2015-09-12T03:00:00.000Z\n2015-09-12T03:00:00.000Z_2015-09-12T04:00:00.000Z\n2015-09-12T04:00:00.000Z_2015-09-12T05:00:00.000Z\n2015-09-12T05:00:00.000Z_2015-09-12T06:00:00.000Z\n2015-09-12T06:00:00.000Z_2015-09-12T07:00:00.000Z\n2015-09-12T07:00:00.000Z_2015-09-12T08:00:00.000Z\n2015-09-12T08:00:00.000Z_2015-09-12T09:00:00.000Z\n2015-09-12T09:00:00.000Z_2015-09-12T10:00:00.000Z\n2015-09-12T10:00:00.000Z_2015-09-12T11:00:00.000Z\n2015-09-12T11:00:00.000Z_2015-09-12T12:00:00.000Z\n2015-09-12T12:00:00.000Z_2015-09-12T13:00:00.000Z\n2015-09-12T13:00:00.000Z_2015-09-12T14:00:00.000Z\n2015-09-12T14:00:00.000Z_2015-09-12T15:00:00.000Z\n2015-09-12T15:00:00.000Z_2015-09-12T16:00:00.000Z\n2015-09-12T16:00:00.000Z_2015-09-12T17:00:00.000Z\n2015-09-12T17:00:00.000Z_2015-09-12T18:00:00.000Z\n2015-09-12T18:00:00.000Z_2015-09-12T19:00:00.000Z\n2015-09-12T19:00:00.000Z_2015-09-12T20:00:00.000Z\n2015-09-12T20:00:00.000Z_2015-09-12T21:00:00.000Z\n2015-09-12T21:00:00.000Z_2015-09-12T22:00:00.000Z\n2015-09-12T22:00:00.000Z_2015-09-12T23:00:00.000Z\n2015-09-12T23:00:00.000Z_2015-09-13T00:00:00.000Z\n")),(0,s.kt)("h2",{id:"disable-segments-by-segment-ids"},"Disable segments by segment IDs"),(0,s.kt)("p",null,'Let\'s disable some segments by their segmentID. This will again mark the segments as "unused", but not remove them from deep storage. You can see the full segmentID for a segment from UI as explained below.'),(0,s.kt)("p",null,"In the ",(0,s.kt)("a",{parentName:"p",href:"http://localhost:8888/unified-console.html#segments"},"segments view"),", click the arrow on the left side of one of the remaining segments to expand the segment entry:"),(0,s.kt)("p",null,(0,s.kt)("img",{alt:"Segments",src:n(3196).Z,title:"Segments",width:"1940",height:"251"})),(0,s.kt)("p",null,"The top of the info box shows the full segment ID, e.g. ",(0,s.kt)("inlineCode",{parentName:"p"},"deletion-tutorial_2015-09-12T14:00:00.000Z_2015-09-12T15:00:00.000Z_2019-02-28T01:11:51.606Z")," for the segment of hour 14."),(0,s.kt)("p",null,"Let's disable the hour 13 and 14 segments by sending a POST request to the Coordinator with this payload"),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-json"},'{\n "segmentIds":\n [\n "deletion-tutorial_2015-09-12T13:00:00.000Z_2015-09-12T14:00:00.000Z_2019-05-01T17:38:46.961Z",\n "deletion-tutorial_2015-09-12T14:00:00.000Z_2015-09-12T15:00:00.000Z_2019-05-01T17:38:46.961Z"\n ]\n}\n')),(0,s.kt)("p",null,"This payload json has been provided at ",(0,s.kt)("inlineCode",{parentName:"p"},"quickstart/tutorial/deletion-disable-segments.json"),". Submit the POST request to Coordinator like this:"),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-bash"},"curl -X 'POST' -H 'Content-Type:application/json' -d @quickstart/tutorial/deletion-disable-segments.json http://localhost:8081/druid/coordinator/v1/datasources/deletion-tutorial/markUnused\n")),(0,s.kt)("p",null,"After that command completes, you should see that the segments for hour 13 and 14 have been disabled:"),(0,s.kt)("p",null,(0,s.kt)("img",{alt:"Segments 3",src:n(3264).Z,title:"Segments 3",width:"3342",height:"1492"})),(0,s.kt)("p",null,"Note that the hour 13 and 14 segments are still in deep storage:"),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-bash"},"$ ls -l1 var/druid/segments/deletion-tutorial/\n2015-09-12T00:00:00.000Z_2015-09-12T01:00:00.000Z\n2015-09-12T01:00:00.000Z_2015-09-12T02:00:00.000Z\n2015-09-12T02:00:00.000Z_2015-09-12T03:00:00.000Z\n2015-09-12T03:00:00.000Z_2015-09-12T04:00:00.000Z\n2015-09-12T04:00:00.000Z_2015-09-12T05:00:00.000Z\n2015-09-12T05:00:00.000Z_2015-09-12T06:00:00.000Z\n2015-09-12T06:00:00.000Z_2015-09-12T07:00:00.000Z\n2015-09-12T07:00:00.000Z_2015-09-12T08:00:00.000Z\n2015-09-12T08:00:00.000Z_2015-09-12T09:00:00.000Z\n2015-09-12T09:00:00.000Z_2015-09-12T10:00:00.000Z\n2015-09-12T10:00:00.000Z_2015-09-12T11:00:00.000Z\n2015-09-12T11:00:00.000Z_2015-09-12T12:00:00.000Z\n2015-09-12T12:00:00.000Z_2015-09-12T13:00:00.000Z\n2015-09-12T13:00:00.000Z_2015-09-12T14:00:00.000Z\n2015-09-12T14:00:00.000Z_2015-09-12T15:00:00.000Z\n2015-09-12T15:00:00.000Z_2015-09-12T16:00:00.000Z\n2015-09-12T16:00:00.000Z_2015-09-12T17:00:00.000Z\n2015-09-12T17:00:00.000Z_2015-09-12T18:00:00.000Z\n2015-09-12T18:00:00.000Z_2015-09-12T19:00:00.000Z\n2015-09-12T19:00:00.000Z_2015-09-12T20:00:00.000Z\n2015-09-12T20:00:00.000Z_2015-09-12T21:00:00.000Z\n2015-09-12T21:00:00.000Z_2015-09-12T22:00:00.000Z\n2015-09-12T22:00:00.000Z_2015-09-12T23:00:00.000Z\n2015-09-12T23:00:00.000Z_2015-09-13T00:00:00.000Z\n")),(0,s.kt)("h2",{id:"run-a-kill-task"},"Run a kill task"),(0,s.kt)("p",null,"Now that we have disabled some segments, we can submit a Kill Task, which will delete the disabled segments from metadata and deep storage."),(0,s.kt)("p",null,"A Kill Task spec has been provided at ",(0,s.kt)("inlineCode",{parentName:"p"},"quickstart/tutorial/deletion-kill.json"),". Submit this task to the Overlord with the following command:"),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-bash"},"curl -X 'POST' -H 'Content-Type:application/json' -d @quickstart/tutorial/deletion-kill.json http://localhost:8081/druid/indexer/v1/task\n")),(0,s.kt)("p",null,"After this task completes, you can see that the disabled segments have now been removed from deep storage:"),(0,s.kt)("pre",null,(0,s.kt)("code",{parentName:"pre",className:"language-bash"},"$ ls -l1 var/druid/segments/deletion-tutorial/\n2015-09-12T12:00:00.000Z_2015-09-12T13:00:00.000Z\n2015-09-12T15:00:00.000Z_2015-09-12T16:00:00.000Z\n2015-09-12T16:00:00.000Z_2015-09-12T17:00:00.000Z\n2015-09-12T17:00:00.000Z_2015-09-12T18:00:00.000Z\n2015-09-12T20:00:00.000Z_2015-09-12T21:00:00.000Z\n2015-09-12T21:00:00.000Z_2015-09-12T22:00:00.000Z\n2015-09-12T22:00:00.000Z_2015-09-12T23:00:00.000Z\n2015-09-12T23:00:00.000Z_2015-09-13T00:00:00.000Z\n")))}T.isMDXComponent=!0},3196:(e,t,n)=>{n.d(t,{Z:()=>a});const a=n.p+"assets/images/tutorial-deletion-01-453be651d572260b06aa674af41d7d4b.png"},325:(e,t,n)=>{n.d(t,{Z:()=>a});const a=n.p+"assets/images/tutorial-deletion-02-c9740838d934e1f6e3cb933ba7183dc9.png"},3264:(e,t,n)=>{n.d(t,{Z:()=>a});const a=n.p+"assets/images/tutorial-deletion-03-7b6fd66b40d1711ef8ee2643a3b57413.png"}}]);