Return-Path: X-Original-To: apmail-cayenne-dev-archive@www.apache.org Delivered-To: apmail-cayenne-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 1CFD818BE8 for ; Wed, 16 Dec 2015 18:10:01 +0000 (UTC) Received: (qmail 45384 invoked by uid 500); 16 Dec 2015 18:10:01 -0000 Delivered-To: apmail-cayenne-dev-archive@cayenne.apache.org Received: (qmail 45372 invoked by uid 500); 16 Dec 2015 18:10:01 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 45352 invoked by uid 99); 16 Dec 2015 18:10:00 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Dec 2015 18:10:00 +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 267E41804FD for ; Wed, 16 Dec 2015 18:10:00 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.1 X-Spam-Level: X-Spam-Status: No, score=-0.1 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=objectstyle.org header.b=NcS6EyVX; dkim=pass (1024-bit key) header.d=messagingengine.com header.b=ckxbqQhJ Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id hnqYHkEI9lfW for ; Wed, 16 Dec 2015 18:09:48 +0000 (UTC) Received: from new1-smtp.messagingengine.com (new1-smtp.messagingengine.com [66.111.4.221]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 6A0A242A45 for ; Wed, 16 Dec 2015 18:09:48 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 0843518B for ; Wed, 16 Dec 2015 13:09:41 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Wed, 16 Dec 2015 13:09:41 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=objectstyle.org; h=content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=c3ogRuFKu8xGrNupts9J0Kw+V6U=; b=NcS6Ey VXe2GgoTQqaRmnsRmWpWlWsyEkIUukmKFgUDKAYp/nJRnZVcvji8jDOXDLK+vXPo sQ6wBg8QK3039ozD1CqxAAovYziHYJfOfE91y027Vqe7kKcNZwu/cvVOBnvw+TpT crcha5XMIWo67RPo8r3ASZBlxp+XlI18gMbvE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=c3ogRuFKu8xGrNu pts9J0Kw+V6U=; b=ckxbqQhJcAYES6QNj3/EYTIPja6QrKV6t6h+fdUsMCHsE1F F095S0vwNygh7WPHN+72sv524J0bspMU43YwLOCyMML44wQJAZ+SJyQwtMesG9Qj Yk16u344cl6hkNh8SNobJkTL2I1bo4iVyagFlAbt/EaNVX0aVtyhxyYUw5+w= X-Sasl-enc: zP24dZO6gcyVkTJEq4CUWKFWhSH6ORPXFn8freOXMMAK 1450289380 Received: from [192.168.4.122] (unknown [212.98.191.4]) by mail.messagingengine.com (Postfix) with ESMTPA id E60ACC016F2 for ; Wed, 16 Dec 2015 13:09:39 -0500 (EST) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Subject: Re: Syncing DataContexts From: Andrus Adamchik In-Reply-To: <110BA5B6-5954-4D07-B230-A6CF533E0839@swarmbox.com> Date: Wed, 16 Dec 2015 21:09:38 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <86484CB6-C1DD-4664-8E42-40C31C219323@objectstyle.org> References: <5663008D.4020903@posteo.de> <5663FA71.4080505@maniatis.org> <5664B18B.3030304@posteo.de> <566D54D0.3000107@posteo.de> <110BA5B6-5954-4D07-B230-A6CF533E0839@swarmbox.com> To: dev@cayenne.apache.org X-Mailer: Apple Mail (2.3112) Hi Matt, > On Dec 15, 2015, at 11:37 PM, Matt Watson wrote: > It is my understanding that if more than one ObjectContext has the = same DataObject, when changes to that object are committed, the other = context that has that same object will automatically be updated with the = changes. But this does not seem to be happening for me. Within the same VM, yes, unless you turn it off explicitly. Try running = in debugger with a breakpoint in ObjectStore.snapshotsChanged(..) method = and see if it is called.=20 > The specific scenario, is that I have two different people receiving = product to the same PurchaseOrderLine. If they both bring in that = PurchaseOrderLine before anything has been received, the = =93receivedQuantity=94 on that POL starts out at 0 (ZERO). When person A = scans a box, the POL.receivedQuantity increments to 1, and then = increments to 2 when he scans another. Then if person B scans a box, = their POL still thinks the =93receivedQuantity=94 is ZERO and it = increments it to 1. So what I have in the database is a POL with = receivedQuantity 1, but there are actually InventoryTransactions showing = that it should be at 3. So I presume you commit after every scan? Again, this would mean the = events should be propagated and merged into objects. > Not sure if this is related but we often see in the log during a = commit -> "snapshot version changed, don't know what to do=85=94 This can be related ... if this happens, IIRC Cayenne does not generate = a snapshot event.=20 > I read the Cayenne docs here = (https://cayenne.apache.org/docs/4.0/cayenne-guide/performance-tuning.html= #turning-off-synchronization-of-objectcontexts = ) that it does not = recommend using synchronization for a large number of users (peer = Contexts), however I tested this with only 2 and still experience the = issue. And now that I have just reread that documentation, I may have = misunderstood that the object is automatically updated, and that instead = the Context is notified of the changes via an event, but if I am not = listening that event (& handling), then that could be why the other = Context does not have the updated information on that object. In addition to poor performance characteristics, snapshot syncing is = prone to various race conditions (e.g. an object property may get = refreshed via an event, but then immediately overwritten from the UI), = so its use is rather limited. I'd personally turn it off and use some = other approach, e.g. optimistic locking in combination with query cache = (query cache which was discussed a few days ago here [1]. Andrus [1] = http://stackoverflow.com/questions/34244260/cayenne-cache-does-query-cache= -replace-object-cache