Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 52E11200D3E for ; Wed, 1 Nov 2017 23:30:07 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 513351609EC; Wed, 1 Nov 2017 22:30:07 +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 9F8D5160BEA for ; Wed, 1 Nov 2017 23:30:06 +0100 (CET) Received: (qmail 50567 invoked by uid 500); 1 Nov 2017 22:30:05 -0000 Mailing-List: contact commits-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 commits@cassandra.apache.org Received: (qmail 50303 invoked by uid 99); 1 Nov 2017 22:30:05 -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; Wed, 01 Nov 2017 22:30:05 +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 CE3EC1842AC for ; Wed, 1 Nov 2017 22:30:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, 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 t0ORzRMU_dZD for ; Wed, 1 Nov 2017 22:30:03 +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 D1A4C60E3E for ; Wed, 1 Nov 2017 22:30:02 +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 02BC4E101B for ; Wed, 1 Nov 2017 22:30:02 +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 81C9D2441A for ; Wed, 1 Nov 2017 22:30:01 +0000 (UTC) Date: Wed, 1 Nov 2017 22:30:01 +0000 (UTC) From: "Jeff Jirsa (JIRA)" To: commits@cassandra.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Issue Comment Deleted] (CASSANDRA-10786) Include hash of result set metadata in prepared statement id MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 01 Nov 2017 22:30:07 -0000 [ https://issues.apache.org/jira/browse/CASSANDRA-10786?page=3Dcom.atl= assian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jeff Jirsa updated CASSANDRA-10786: ----------------------------------- Comment: was deleted (was: Sehr geehrte Damen und Herren, ich bin bis zum 06.11.2017 nicht im Haus. Bei dringenden Angelegenheiten we= nden Sie sich bitte an Herrn Gugliotta unter der Mailadresse rgugliotta@oph= ardt.com oder telefonisch =C3=BCber +49283518453. Mit freundlichen Gr=C3=BC=C3=9Fen Adam Wehner ) > Include hash of result set metadata in prepared statement id > ------------------------------------------------------------ > > Key: CASSANDRA-10786 > URL: https://issues.apache.org/jira/browse/CASSANDRA-1078= 6 > Project: Cassandra > Issue Type: Sub-task > Components: CQL > Reporter: Olivier Michallat > Assignee: Alex Petrov > Priority: Minor > Labels: client-impacting, doc-impacting, protocolv5 > Fix For: 4.0 > > > {color:red} > Warning for implementors: the spec has a typo, see CASSANDRA-13986 > {color} > *_Initial description:_* > This is a follow-up to CASSANDRA-7910, which was about invalidating a pre= pared statement when the table is altered, to force clients to update their= local copy of the metadata. > There's still an issue if multiple clients are connected to the same host= . The first client to execute the query after the cache was invalidated wil= l receive an UNPREPARED response, re-prepare, and update its local metadata= . But other clients might miss it entirely (the MD5 hasn't changed), and th= ey will keep using their old metadata. For example: > # {{SELECT * ...}} statement is prepared in Cassandra with md5 abc123, cl= ientA and clientB both have a cache of the metadata (columns b and c) local= ly > # column a gets added to the table, C* invalidates its cache entry > # clientA sends an EXECUTE request for md5 abc123, gets UNPREPARED respon= se, re-prepares on the fly and updates its local metadata to (a, b, c) > # prepared statement is now in C*=E2=80=99s cache again, with the same md= 5 abc123 > # clientB sends an EXECUTE request for id abc123. Because the cache has b= een populated again, the query succeeds. But clientB still has not updated = its metadata, it=E2=80=99s still (b,c) > One solution that was suggested is to include a hash of the result set me= tadata in the md5. This way the md5 would change at step 3, and any client = using the old md5 would get an UNPREPARED, regardless of whether another cl= ient already reprepared. > ----- > *_Resolution (2017/02/13):_* > The following changes were made to native protocol v5: > - the PREPARED response includes {{result_metadata_id}}, a hash of the re= sult set metadata. > - every EXECUTE message must provide {{result_metadata_id}} in addition t= o the prepared statement id. If it doesn't match the current one on the ser= ver, it means the client is operating on a stale schema. > - to notify the client, the server returns a ROWS response with a new {{M= etadata_changed}} flag, the new {{result_metadata_id}} and the updated resu= lt metadata (this overrides the {{No_metadata}} flag, even if the client ha= d requested it) > - the client updates its copy of the result metadata before it decodes th= e results. > So the scenario above would now look like: > # {{SELECT * ...}} statement is prepared in Cassandra with md5 abc123, an= d result set (b, c) that hashes to cde456 > # column a gets added to the table, C* does not invalidate its cache entr= y, but only updates the result set to (a, b, c) which hashes to fff789 > # client sends an EXECUTE request for (statementId=3Dabc123, resultId=3Dc= de456) and skip_metadata flag > # cde456!=3Dfff789, so C* responds with ROWS(..., no_metadata=3Dfalse, me= tadata_changed=3Dtrue, new_metadata_id=3Dfff789,col specs for (a,b,c)) > # client updates its column specifications, and will send the next execut= e queries with (statementId=3Dabc123, resultId=3Dfff789) > This works the same with multiple clients. -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org For additional commands, e-mail: commits-help@cassandra.apache.org