From user-return-59416-archive-asf-public=cust-asf.ponee.io@cassandra.apache.org Tue Jan 16 15:36:57 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id B7DEF18065B for ; Tue, 16 Jan 2018 15:36:57 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A842E160C34; Tue, 16 Jan 2018 14:36:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7BB1E160C26 for ; Tue, 16 Jan 2018 15:36:56 +0100 (CET) Received: (qmail 84266 invoked by uid 500); 16 Jan 2018 14:36:54 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 84256 invoked by uid 99); 16 Jan 2018 14:36:54 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jan 2018 14:36:54 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 1B97C18062E for ; Tue, 16 Jan 2018 14:36:54 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.933 X-Spam-Level: * X-Spam-Status: No, score=1.933 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=thelastpickle-com.20150623.gappssmtp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id xpw9M8zfhouC for ; Tue, 16 Jan 2018 14:36:51 +0000 (UTC) Received: from mail-qt0-f179.google.com (mail-qt0-f179.google.com [209.85.216.179]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 793E45F39D for ; Tue, 16 Jan 2018 14:36:51 +0000 (UTC) Received: by mail-qt0-f179.google.com with SMTP id i1so1599814qtj.8 for ; Tue, 16 Jan 2018 06:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thelastpickle-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=BV34ljlc2GzN5QDAWTw7/avit/KOvDz/4JpVMzYlPlE=; b=GvTcIP715sHiv7DWULp4g/rBruQZqZ+A9YaBqFhv0iuH/p25OhIMMM1oETBInuAPdg aniTUJbPxntFT0Dn4qutSKcat8m5Xqjyu4k4yz/kh/SNYD/3B/VHpSIIC+55TooBdCbv 2gz8jM6gqi8sNjJ43Y9illQ/Dn5aSTaJ9O4PNqU+/3T1gL5FXtsBy+kedimPkX/DlqZX kIhaI7bZnAo1XIFH3UHQTJPPsCWbaGnY6QU8s4YDxUYIAlD380MMNUqhkosABT1KV4PJ X5T48c2/BcDMz7fphY1mcISJDlbexc+1x+qq36FJAcg1N3/uI5QkVe3QxcAD+QnBBXE/ YZdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=BV34ljlc2GzN5QDAWTw7/avit/KOvDz/4JpVMzYlPlE=; b=K5IRxZapHrBfM4vQLLwbM+MK3SYTIqEREHutN9Q8ayD1ZtrNo6ghkncS0wYf35lYjN vFKz8DYNHjx6tdkDnep2TiXcfXIYbqQd0bCmnspIVcI0OLYR5cUHyTl82kJU38XIoMNE 7khFCPxxPNPNrqTBB/uoSrz+CdgGx6j8kSJHtPbF60tT6t3OAO7tfmbyKvk5txdktccJ Oo10KfeRjg1pdR3k/z9BvtQWCqUnDAjortWVk/sRB4srgei4TRVq+7L0q8bL6SQGvmGN XZMc5K93LC+s/F8J/xDayqC9VxwVoI2v91I7xN4vPHH650UxqtqXHrsyWtUXo7XUBlCx 51Bg== X-Gm-Message-State: AKwxytcptccEkQOWzIJl4YU+zclS/ycETMp+o60v4fIMbBgShvgeYKQ+ IAk+NhkmE80dKKy4Qm/bhwI+oYXLUJgqTauuzNSv8ki7 X-Google-Smtp-Source: ACJfBovlJmaKR/iC4DY3oIl0WK4cBpJ+AgdQIwbELR9RZv/uH3lelkQY9Jm+gfwhqNy2hrwcUMpDfDk5F8q8/kXi6bk= X-Received: by 10.237.62.252 with SMTP id o57mr2708706qtf.54.1516113410883; Tue, 16 Jan 2018 06:36:50 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Alexander Dejanovski Date: Tue, 16 Jan 2018 14:36:40 +0000 Message-ID: Subject: Re: Too many tombstones using TTL To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary="001a113e10044b95740562e5a959" --001a113e10044b95740562e5a959 Content-Type: text/plain; charset="UTF-8" I would not plan on deleting data at the row level as you'll end up with a lot of tombstones eventually (and you won't even notice them). It's not healthy to allow that many tombstones to be read, and while your latency may fit your SLA now, it may not in the future. Tombstones are going to create a lot of heap pressure and eventually trigger long GC pauses, which then tend to affect the whole cluster (a slow node is worse than a down node). You should definitely separate data that is TTLed and data that is not in different tables so that you can adjust compaction strategies, gc_grace_seconds and read patterns accordingly. I understand that it will complexify your code, but it will prevent severe performance issues in Cassandra. Tombstones won't be a problem for repair, they will get repaired as classic cells. They negatively affect the read path mostly, and use space on disk. On Tue, Jan 16, 2018 at 2:12 PM Python_Max wrote: > Hello. > > I was planning to remove a row (not partition). > > Most of the tombstones are seen in the use case of geographic grid with > X:Y as partition key and object id (timeuuid) as clustering key where > objects could be temporary with TTL about 10 hours or fully persistent. > When I select all objects in specific X:Y I can even hit 100k (default) > limit for some X:Y. I have changed this limit to 500k since 99.9p read > latency is < 75ms so I should not (?) care how many tombstones while read > latency is fine. > > Splitting entities to temporary and permanent and using different > compaction strategies is an option but it will lead to code duplication and > 2x read queries. > > Is my assumption correct about tombstones are not so big problem as soon > as read latency and disk usage are okey? Are tombstones affect repair time > (using reaper)? > > Thanks. > > > On Tue, Jan 16, 2018 at 11:32 AM, Alexander Dejanovski < > alex@thelastpickle.com> wrote: > >> Hi, >> >> could you be more specific about the deletes you're planning to perform ? >> This will end up moving your problem somewhere else as you'll be >> generating new tombstones (and if you're planning on deleting rows, be >> aware that row level tombstones aren't reported anywhere in the metrics, >> logs and query traces). >> Currently you can delete your data at the partition level, which will >> create a single tombstone that will shadow all your expired (and non >> expired) data and is very efficient. The read path is optimized for such >> tombstones and the data won't be fully read from disk nor exchanged between >> replicas. But that's of course if your use case allows to delete full >> partitions. >> >> We usually model so that we can restrict our reads to live data. >> If you're creating time series, your clustering key should include a >> timestamp, which you can use to avoid reading expired data. If your TTL is >> set to 60 days, you can read only data that is strictly younger than that. >> Then you can partition by time ranges, and access exclusively partitions >> that have no chance to be expired yet. >> Those techniques usually work better with TWCS, but the former could make >> you hit a lot of SSTables if your partitions can spread over all time >> buckets, so only use TWCS if you can restrict individual reads to up to 4 >> time windows. >> >> Cheers, >> >> >> On Tue, Jan 16, 2018 at 10:01 AM Python_Max wrote: >> >>> Hi. >>> >>> Thank you very much for detailed explanation. >>> Seems that there is nothing I can do about it except delete records by >>> key instead of expiring. >>> >>> >>> On Fri, Jan 12, 2018 at 7:30 PM, Alexander Dejanovski < >>> alex@thelastpickle.com> wrote: >>> >>>> Hi, >>>> >>>> As DuyHai said, different TTLs could theoretically be set for different >>>> cells of the same row. And one TTLed cell could be shadowing another cell >>>> that has no TTL (say you forgot to set a TTL and set one afterwards by >>>> performing an update), or vice versa. >>>> One cell could also be missing from a node without Cassandra knowing. >>>> So turning an incomplete row that only has expired cells into a tombstone >>>> row could lead to wrong results being returned at read time : the tombstone >>>> row could potentially shadow a valid live cell from another replica. >>>> >>>> Cassandra needs to retain each TTLed cell and send it to replicas >>>> during reads to cover all possible cases. >>>> >>>> >>>> On Fri, Jan 12, 2018 at 5:28 PM Python_Max >>>> wrote: >>>> >>>>> Thank you for response. >>>>> >>>>> I know about the option of setting TTL per column or even per item in >>>>> collection. However in my example entire row has expired, shouldn't >>>>> Cassandra be able to detect this situation and spawn a single tombstone for >>>>> entire row instead of many? >>>>> Is there any reason not doing this except that no one needs it? Is >>>>> this suitable for feature request or improvement? >>>>> >>>>> Thanks. >>>>> >>>>> On Wed, Jan 10, 2018 at 4:52 PM, DuyHai Doan >>>>> wrote: >>>>> >>>>>> "The question is why Cassandra creates a tombstone for every column >>>>>> instead of single tombstone per row?" >>>>>> >>>>>> --> Simply because technically it is possible to set different TTL >>>>>> value on each column of a CQL row >>>>>> >>>>>> On Wed, Jan 10, 2018 at 2:59 PM, Python_Max >>>>>> wrote: >>>>>> >>>>>>> Hello, C* users and experts. >>>>>>> >>>>>>> I have (one more) question about tombstones. >>>>>>> >>>>>>> Consider the following example: >>>>>>> cqlsh> create keyspace test_ttl with replication = {'class': >>>>>>> 'SimpleStrategy', 'replication_factor': '1'}; use test_ttl; >>>>>>> cqlsh> create table items(a text, b text, c1 text, c2 text, c3 text, >>>>>>> primary key (a, b)); >>>>>>> cqlsh> insert into items(a,b,c1,c2,c3) values('AAA', 'BBB', 'C111', >>>>>>> 'C222', 'C333') using ttl 60; >>>>>>> bash$ nodetool flush >>>>>>> bash$ sleep 60 >>>>>>> bash$ nodetool compact test_ttl items >>>>>>> bash$ sstabledump mc-2-big-Data.db >>>>>>> >>>>>>> [ >>>>>>> { >>>>>>> "partition" : { >>>>>>> "key" : [ "AAA" ], >>>>>>> "position" : 0 >>>>>>> }, >>>>>>> "rows" : [ >>>>>>> { >>>>>>> "type" : "row", >>>>>>> "position" : 58, >>>>>>> "clustering" : [ "BBB" ], >>>>>>> "liveness_info" : { "tstamp" : "2018-01-10T13:29:25.777Z", >>>>>>> "ttl" : 60, "expires_at" : "2018-01-10T13:30:25Z", "expired" : true }, >>>>>>> "cells" : [ >>>>>>> { "name" : "c1", "deletion_info" : { "local_delete_time" : >>>>>>> "2018-01-10T13:29:25Z" } >>>>>>> }, >>>>>>> { "name" : "c2", "deletion_info" : { "local_delete_time" : >>>>>>> "2018-01-10T13:29:25Z" } >>>>>>> }, >>>>>>> { "name" : "c3", "deletion_info" : { "local_delete_time" : >>>>>>> "2018-01-10T13:29:25Z" } >>>>>>> } >>>>>>> ] >>>>>>> } >>>>>>> ] >>>>>>> } >>>>>>> ] >>>>>>> >>>>>>> The question is why Cassandra creates a tombstone for every column >>>>>>> instead of single tombstone per row? >>>>>>> >>>>>>> In production environment I have a table with ~30 columns and It >>>>>>> gives me a warning for 30k tombstones and 300 live rows. It is 30 times >>>>>>> more then it could be. >>>>>>> Can this behavior be tuned in some way? >>>>>>> >>>>>>> Thanks. >>>>>>> >>>>>>> -- >>>>>>> Best regards, >>>>>>> Python_Max. >>>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Best regards, >>>>> Python_Max. >>>>> >>>> >>>> >>>> -- >>>> ----------------- >>>> Alexander Dejanovski >>>> France >>>> @alexanderdeja >>>> >>>> Consultant >>>> Apache Cassandra Consulting >>>> http://www.thelastpickle.com >>>> >>> >>> >>> >>> -- >>> Best regards, >>> Python_Max. >>> >> >> >> -- >> ----------------- >> Alexander Dejanovski >> France >> @alexanderdeja >> >> Consultant >> Apache Cassandra Consulting >> http://www.thelastpickle.com >> > > > > -- > Best regards, > Python_Max. > -- ----------------- Alexander Dejanovski France @alexanderdeja Consultant Apache Cassandra Consulting http://www.thelastpickle.com --001a113e10044b95740562e5a959 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I would not plan on deleting data at the row level as you&= #39;ll end up with a lot of tombstones eventually (and you won't even n= otice them).
It's not healthy to allow that many tombstones to be r= ead, and while your latency may fit your SLA now, it may not in the future.=
Tombstones are going to create a lot of heap pressure and eventu= ally trigger long GC pauses, which then tend to affect the whole cluster (a= slow node is worse than a down node).

You should = definitely separate data that is TTLed and data that is not in different ta= bles so that you can adjust compaction strategies, gc_grace_seconds and rea= d patterns accordingly. I understand that it will complexify your code, but= it will prevent severe performance issues in Cassandra.

Tombstones won't be a problem for repair, they will get repaired= as classic cells. They negatively affect the read path mostly, and use spa= ce on disk.

On T= ue, Jan 16, 2018 at 2:12 PM Python_Max <python.max@gmail.com> wrote:
Hello.

I was planning to remov= e a row (not partition).

Most of the tombstones ar= e seen in the use case of geographic grid with X:Y as partition key and obj= ect id (timeuuid) as clustering key where objects could be temporary with T= TL about 10 hours or fully persistent.
When I select all obje= cts in specific X:Y I can even hit 100k (default) limit=C2=A0for some X:Y. = I have changed this limit to 500k since 99.9p read latency is < 75ms so = I should not (?) care how many tombstones while read latency is fine.
=

Splitting entities to temporary and permanent and using= different compaction strategies is an option but it will lead to code dupl= ication and 2x read queries.

Is my assumption corr= ect about tombstones are not so big problem as soon as read latency and dis= k usage are okey? Are tombstones affect repair time (using reaper)?

Thanks.


On Tue,= Jan 16, 2018 at 11:32 AM, Alexander Dejanovski <alex@thelastpickle.c= om> wrote:
Hi,

could you be more specific about the deletes you= 9;re planning to perform ?
This will end up moving your problem s= omewhere else as you'll be generating new tombstones (and if you're= planning on deleting rows, be aware that row level tombstones aren't r= eported anywhere in the metrics, logs and query traces).
Currentl= y you can delete your data at the partition level, which will create a sing= le tombstone that will shadow all your expired (and non expired) data and i= s very efficient. The read path is optimized for such tombstones and the da= ta won't be fully read from disk nor exchanged between replicas. But th= at's of course if your use case allows to delete full partitions.

We usually model so that we can restrict our reads = to live data.=C2=A0
If you're creating time series, your clus= tering key should include a timestamp, which you can use to avoid reading e= xpired data. If your TTL is set to 60 days, you can read only data that is = strictly younger than that.
Then you can partition by time ranges= , and access exclusively partitions that have no chance to be expired yet.<= /div>
Those techniques usually work better with TWCS, but the former co= uld make you hit a lot of SSTables if your partitions can spread over all t= ime buckets, so only use TWCS if you can restrict individual reads to up to= 4 time windows.

Cheers,


On Tue, Jan 16, 2= 018 at 10:01 AM Python_Max <python.max@gmail.com> wrote:
Hi.

Thank you very much = for detailed explanation.
Seems that there is nothing I can do ab= out it except delete records by key instead of expiring.


On Fri, Jan 12, 2018 at 7:30 PM, Alexander Dejanovs= ki <alex@thelastpickle.com> wrote:
Hi,=C2=A0

As DuyHai sai= d, different TTLs could theoretically be set for different cells of the sam= e row. And one TTLed cell could be shadowing another cell that has no TTL (= say you forgot to set a TTL and set one afterwards by performing an update)= , or vice versa.
One cell could also be missing from a node witho= ut Cassandra knowing. So turning an incomplete row that only has expired ce= lls into a tombstone row could lead to wrong results being returned at read= time : the tombstone row could potentially shadow a valid live cell from a= nother replica.

Cassandra needs to retain each TTL= ed cell and send it to replicas during reads to cover all possible cases.


On Fri, Jan 12, 2018 at 5:28 PM Python_Max <python.max@gmail.com>= ; wrote:
Thank you= for response.

I know about the option of setting TTL pe= r column or even per item in collection. However in my example entire row h= as expired, shouldn't Cassandra be able to detect this situation and sp= awn a single tombstone for entire row instead of many?
Is there a= ny reason not doing this except that no one needs it? Is this suitable for = feature request or improvement?

Thanks.

On Wed, Jan 10, 2018 at 4:52 PM, DuyHai Doan <doanduyh= ai@gmail.com> wrote:
"The question is why= Cassandra creates a tombstone for every column instead of single tombstone= per row?"=C2=A0

--> Simply because = technically it is possible to set different TTL value on each column of a C= QL row

On Wed, Jan 10, 2018 at 2:59 PM, Pyt= hon_Max <python.max@gmail.com> wrote:
Hello, C* users and experts.

=
I have (one more) question about tombstones.

= Consider the following example:
cqlsh> create keyspace tes= t_ttl with replication =3D {'class': 'SimpleStrategy', '= ;replication_factor': '1'}; use test_ttl;
cqlsh&g= t;=C2=A0create table items(a text, b text, c1 text, c2 text, c3 text, prima= ry key (a, b));
cqlsh>=C2=A0insert into items(a,b,c1,c2,c3) va= lues('AAA', 'BBB', 'C111', 'C222', 'C33= 3') using ttl 60;
bash$ nodetool flush
bash$ sleep = 60
bash$ nodetool=C2=A0compact test_ttl items
bash$ sst= abledump=C2=A0mc-2-big-Data.db

[<= /div>
=C2=A0 {
=C2=A0 =C2=A0 "partition" : {
<= div>=C2=A0 =C2=A0 =C2=A0 "key" : [ "AAA" ],
= =C2=A0 =C2=A0 =C2=A0 "position" : 0
=C2=A0 =C2=A0 },
=C2=A0 =C2=A0 "rows" : [
=C2=A0 =C2=A0 =C2=A0 {=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "type" : "row",<= /div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "position" : 58,
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 "clustering" : [ "BBB" ],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "liveness_info" : { "ts= tamp" : "2018-01-10T13:29:25.777Z", "ttl" : 60, &q= uot;expires_at" : "2018-01-10T13:30:25Z", "expired"= ; : true },
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "cells" : [
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 { "name" : "c1&quo= t;, "deletion_info" : { "local_delete_time" : "201= 8-01-10T13:29:25Z" }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 },
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 { "name" : "c2&q= uot;, "deletion_info" : { "local_delete_time" : "2= 018-01-10T13:29:25Z" }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 },=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 { "name" : "c3= ", "deletion_info" : { "local_delete_time" : "= ;2018-01-10T13:29:25Z" }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ]
=C2=A0 =C2=A0 =C2=A0 }<= /div>
=C2=A0 =C2=A0 ]
=C2=A0 }
]
The question is why Cassandra creates a tombstone for every co= lumn instead of single tombstone per row?

In produ= ction environment I have a table with ~30 columns and It gives me a warning= for 30k tombstones and 300 live rows. It is 30 times more then it could be= .
Can this behavior be tuned in some way?

Thanks.

--
Best regards,
Python_Max.




<= div class=3D"gmail_extra">--
Best regards,=
Python_Max.


--
-----------------
Alexander Dejanov= ski
France
@ale= xanderdeja

Consultant
Apache Cassandra Consulting
=



--
Best regards,
Python_Max.


--
-------= ----------
Alexander Dejanovski
France
@alexanderdeja
<= div style=3D"font-family:"helvetica neue",helvetica,arial,sans-se= rif;line-height:19.5px">
Consultant
=
Apache Cassandra Consulting



<= div class=3D"gmail_extra">--
Best regards,
= Python_Max.


--
<= div style=3D"font-family:"helvetica neue",helvetica,arial,sans-se= rif;line-height:19.5px">-----------------
Ale= xander Dejanovski
France
@alexanderdeja

Consultant
Apache Cassandra Co= nsulting
--001a113e10044b95740562e5a959--