Return-Path: X-Original-To: apmail-cassandra-dev-archive@www.apache.org Delivered-To: apmail-cassandra-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 69D0FE141 for ; Fri, 25 Jan 2013 17:23:28 +0000 (UTC) Received: (qmail 55946 invoked by uid 500); 25 Jan 2013 17:23:27 -0000 Delivered-To: apmail-cassandra-dev-archive@cassandra.apache.org Received: (qmail 55923 invoked by uid 500); 25 Jan 2013 17:23:27 -0000 Mailing-List: contact dev-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list dev@cassandra.apache.org Received: (qmail 55915 invoked by uid 99); 25 Jan 2013 17:23:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jan 2013 17:23:27 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jasedbrown@gmail.com designates 209.85.210.47 as permitted sender) Received: from [209.85.210.47] (HELO mail-da0-f47.google.com) (209.85.210.47) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jan 2013 17:23:20 +0000 Received: by mail-da0-f47.google.com with SMTP id s35so263551dak.20 for ; Fri, 25 Jan 2013 09:23:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=nAKuImQDj74/k4G0NzJq0oOZ0DqJivC+lpNTq3eEdFY=; b=VM019B3RmFFdBJF35kvOhrHRDpAXWYYbJSLLAxeZA7nQyH9hb4iJz96xG9ZtRY48hx OQyKL+HP+vB6+8jw4F7g4++gPEMqTlwBG9tYhn/saqh5OpTwkhqqsgxCeuRDbnlqzsCg SpjbjVV2a8BK2TaZOaqVu0gbZQm9xXpEjpdFsGyhaEhtPMvbQN4kZnb3ohi7irT0mBPA e51EFzMXkayKgtcwvl9ji8YoPoAQQJqvCrExrduXH7W2nK7ob6c+FBTrgZcrG/ltLzkG hkPdRnjjEixO/epzQJoAXdhgd7LZyAfMFX5oSvt7gpIgD0MYnn6MNH5XPjOGmOYMxP+l Q8Ig== MIME-Version: 1.0 X-Received: by 10.68.230.135 with SMTP id sy7mr16043002pbc.76.1359134580525; Fri, 25 Jan 2013 09:23:00 -0800 (PST) Received: by 10.68.220.170 with HTTP; Fri, 25 Jan 2013 09:23:00 -0800 (PST) Date: Fri, 25 Jan 2013 09:23:00 -0800 Message-ID: Subject: system schema updates From: Jason Brown To: dev@cassandra.apache.org Content-Type: multipart/alternative; boundary=047d7b339cebdfc9ff04d4202dde X-Virus-Checked: Checked by ClamAV on apache.org --047d7b339cebdfc9ff04d4202dde Content-Type: text/plain; charset=ISO-8859-1 Hi all, I'm working on a ticket that will require an update to one of the system tables. Now that we're using system tables with defined schema, starting with 1.2, the question becomes how to update existing tables. Currently, most, if not all, of the system tables have their CREATE TABLE statements hard-coded in the CFMetaData class. It seems to me that adding an update statment to this class everytime we make a system change will be a bit awkward, as well as working in the logic of determining which update to apply when updating c* versions may get hairy. Hence, I propose a schema migration system where we keep all system schema changes stored as flat files (perhaps in a new 'conf/migrations' directory). Each file would have a unique numeric id (monotinically incrementing) to identify the migration version, thus implying order between the migrations. The migration version could be stored in the file itself, but probably easier to store in the file name, preferably as the first token in the file to allow easier sorting. (This is how I've done it before.) We would then have a new system table to tack the current migration status, system.migration, which would look something like this: use system; create table migration (version int); At c* startup, it would read the system.migration.version value, and compare against the migration files' ids. If the stored value is lower, the higher numbered migration files would be applied. This would be a minor cost at upgrade time (most of which you would have to incur, anyways, because of the upgrade), but virtually free any other time. It allows us to have better visibility into system schema change over time, as well. I'm happy to jump in and start working on this if the community thinks it a worthwhile addition. Thanks, -Jason Brown Netflix --047d7b339cebdfc9ff04d4202dde--