[ 
https://issues.apache.org/jira/browse/CASSANDRA-17372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17491717#comment-17491717
 ] 

Paulo Motta commented on CASSANDRA-17372:
-----------------------------------------

{quote}I'd personally be inclined to keep it simple, and just document it. Any 
distributed mechanism for enforcing this will be more difficult to get right 
than it's worth (particularly in ongoing maintenance).
{quote}
I think we should prevent surprising behaviors by default versus relying on 
users to read the manual.

Here is a rough draft of how to potentially achieve this with accord:
{code:python}
def update_ttl(self, new_ttl, override=False):
  if not override and min_cluster_timestamp.get() > (now() - self.current_ttl):
    raise InvalidRequestException("cannot update TTL")
  self.current_ttl = new-ttl

class MinClusterTimestamp:
  
  def init(tracker, cluster, accord):
    self.tracker = tracker
    self.cluster = cluster
    self.accord = accord
    self.min_cluster_timestamp = {}
    self.refresh()
    schedule.every(1).hours.do(self.refresh)

  def on_join(self, node):
    refresh(node)

  def refresh(self):
    for node in cluster.members():
      self.refresh_node(node)

  def refresh_node(self, node):
    if node == LOCAL:
      self.accord[f"min_local_timestamp:{node.id}"] = 
self.min_local_timestamp():
    self.min_cluster_timestamp[node] = 
self.accord.get(f"min_local_timestamp:{node.id}", MIN_TIMESTAMP)

  def min_local_timestamp(self):
    return min(map(lambda s : s.min_live_timestamp, self.tracker.sstables), 
default=now())

  def get(self):
    return min(self.min_cluster_timestamp)
{code}

> Dynamic Table TTL
> -----------------
>
>                 Key: CASSANDRA-17372
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-17372
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: CQL/Semantics
>            Reporter: Paulo Motta
>            Priority: Normal
>
> One limitation of the {{default_time_to_live}} option is that it only applies 
> to newly inserted data so an expensive migration is required when altering 
> the table-level TTL, which is not an uncommon request due to changes in 
> retention policies.
> This seems to have been a deliberate design decision when adding the Table 
> TTL feature on CASSANDRA-3974, due to the reasons stated [on this 
> comment|https://issues.apache.org/jira/browse/CASSANDRA-3974?focusedCommentId=13427314&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-13427314]
>  so we should revisit and potentially address these concerns.
> I would like to explore supporting dynamic TTL, which would reflect any 
> updates to the table-level {{default_time_to_live}} immediately to all table 
> data.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to