From oak-issues-return-63386-archive-asf-public=cust-asf.ponee.io@jackrabbit.apache.org Fri Jul 13 13:52:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id AC739180626 for ; Fri, 13 Jul 2018 13:52:04 +0200 (CEST) Received: (qmail 54899 invoked by uid 500); 13 Jul 2018 11:52:03 -0000 Mailing-List: contact oak-issues-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-issues@jackrabbit.apache.org Received: (qmail 54888 invoked by uid 99); 13 Jul 2018 11:52:03 -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; Fri, 13 Jul 2018 11:52:03 +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 3FC42180162 for ; Fri, 13 Jul 2018 11:52:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.301 X-Spam-Level: X-Spam-Status: No, score=-110.301 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id qGTZC5xlBHAb for ; Fri, 13 Jul 2018 11:52:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 5783A5F3BC for ; Fri, 13 Jul 2018 11:52:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 7FA40E1024 for ; Fri, 13 Jul 2018 11:52:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 1753823F96 for ; Fri, 13 Jul 2018 11:52:00 +0000 (UTC) Date: Fri, 13 Jul 2018 11:52:00 +0000 (UTC) From: "Vikas Saurabh (JIRA)" To: oak-issues@jackrabbit.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (OAK-7246) Improve cleanup of locally copied index files MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/OAK-7246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16542944#comment-16542944 ] Vikas Saurabh commented on OAK-7246: ------------------------------------ Discussed this a bit with [~tmueller] and [~chetanm] for a simpler and safer approach to fix clean up. We need this constraint to hold - only files which would not longer be required should be deleted Given how files are created on local disk (due to CoR or CoW), we'd (probably fairly) assume these: * creation timestamps of local files would follow the same sequence as revisions being observed(CoR)/created(CoW) * files created before any of the files visible to a closing reader won't be required in the future (it's basically a corollary of the point above - but is still important to state explicitly) Given these, a simple approach for clean up could be that the closing readers, while being closed, schedules deletion of files resulting from following steps: # get timestamps of local files which are visible on its revision - set max of these timestamps as T ~max~ # get set of local files as S ~local~ # subtract files visible on its revision from S ~local~ to get S ~candidate~ # filter S ~candidate~ by "keep if {{creation timestamp}} < T ~max~ to get S ~delete~ # schedule files listed in S ~delete~ to be deleted With this approach, we can entirely get rid of shared set being maintained by writers. Similarly, we don't need to maintain {{localFileNames}} in {{CopyOnReadDirectory}} as a snapshot of files available locally when the reader was being opened. > Improve cleanup of locally copied index files > --------------------------------------------- > > Key: OAK-7246 > URL: https://issues.apache.org/jira/browse/OAK-7246 > Project: Jackrabbit Oak > Issue Type: Improvement > Components: lucene > Reporter: Vikas Saurabh > Assignee: Vikas Saurabh > Priority: Major > > This task is to re-think how should we do clean up of locally copied index files which are no longer in use. > Current approach: > # index writers, while creating index files, keep list of currently-being-written files > ## this list is cleared when a new index writer comes into play > # index tracker opens new index (at new revision) via observation > ## while being opened, we also track current dir listing of the local index files > # during opening new index, the tracker closes the old revision of index reader > ## during this close, local files noted above during open are purged if ( they don't show up in remote view of the index && they aren't part of currently being written list by index writer) > This approach, at least in following timeline, would incur extra copying (and as a side-effect also open some index files directly off of remote input stream during CoWs): > # CoW1 creates [a, b] > # CoW2 starts and creates [c, d], removes [a, b] from remote > # CoR1 opens an index due to CoW1 > ## local-list-CoR1 = [a, b, c, d], remote-index-list=[a, b] > # CoW2 finishes > # CoW3 creates [e, f], removes [a,b] from remote > ## CoW-currently-being-written-list=[e,f] > # CoR2 opens due to CoW2 > ## local-list-CoR2=[a,b,c,d,e,f], remote-index-list=[c,d] > # CoR1 closes > ## deletes [c,d] as they aren't in its list of index files ([a,b]) AND aren't part of shared list ([e,f]) > Disclaimer: the timeline might be off a bit (haven't written a test yet... but the basic point is that CoR could be working with a index file set and the new files might have come in twice after CoR - thus shared list doesn't have complete information of new files written in. > [~chetanm], can you please check the timeline above - I'd try to work on a test case in the mean time. -- This message was sent by Atlassian JIRA (v7.6.3#76005)