Are table operations atomic?

In a traditional ACID database, when an error occurs inside atransaction, any updates made previously in the transaction are eitherrolled back or simply thrown away.I expected q’s table operations to behave the same way. However, thisappears not to be the case. Consider the following example:KDB+ 2.7 2010.11.30 Copyright (C) 1993-2010 Kx Systemsm32/ 2()core 4096MB andy mini.private 255.255.255.255 PLAY 2011.02.28q)t:( c1:abc; c2:10 20 30)q)@[t;0;:;(aa;99f)]'typeq)tc1 c2-----aa 10b 20c 30The partial update to the first column survives even though theoverall call to @ fails. The same thing happens with directassignment:q)t[0]:(bb;98f)'typeq)tc1 c2-----bb 10b 20c 30Really?

Take a look at:

https://code.kx.com/trac/wiki/Cookbook/Logging

Thanks for link.I’ve tried it, but I cannot get it to automatically rollback, and getthe initial table when the update fails.The original data is restored (from logs) only if I restart the qprocess.Is this the way it is supposed to work?PMOn Feb 14, 10:28?pm, Tim Rieder <trie…> wrote:> Take ?a look at:>> https://code.kx.com/trac/wiki/Cookbook/Logging&gt;&gt; On Sun, Feb 13, 2011 at 7:54 AM, andyturk <andyt…> wrote:> > In a traditional ACID database, when an error occurs inside a> > transaction, any updates made previously in the transaction are either> > rolled back or simply thrown away.>> > I expected q’s table operations to behave the same way. However, this> > appears not to be the case. Consider the following example:>> > KDB+ 2.7 2010.11.30 Copyright (C) 1993-2010 Kx Systems> > m32/ 2()core 4096MB andy mini.private 255.255.255.255 PLAY 2011.02.28>> > q)t:( c1:abc; c2:10 20 30)&gt; &gt; q)@[t;0;:;(aa;99f)]&gt; &gt; 'type&gt; &gt; q)t&gt; &gt; c1 c2&gt; &gt; -----&gt; &gt; aa 10&gt; &gt; b ?20&gt; &gt; c ?30&gt;&gt; &gt; The partial update to the first column survives even though the&gt; &gt; overall call to @ fails. The same thing happens with direct&gt; &gt; assignment:&gt;&gt; &gt; q)t[0]:(bb;98f)> > 'type> > q)t> > c1 c2> > -----> > bb 10> > b ?20> > c ?30>> > Really?>> > –> >

Submitted via Google Groups</andyt…></trie…>

you don’t provide an example 

but I’d guess you overlooked:

“…Now update messages from clients are logged…”


from the link Tim sent

using -l sets you up a server which has logging enabled for client messages 

NOT for commands typed in at the console 

try talking to your server from a client task, or for quick testing fooling it by using the handle 0

q)0"bb:17;aa:2 3+4 5 6"

rollback

'length

q)bb

'bb

q)aa

'aa

Thanks for reply.Here is an example:$> q test -lKDB+ 2.7 2010.12.06 Copyright (C) 1993-2010 Kx Systems…q).z.ftestq)t:([] s:abc; i:1 2 3)q)\lq)ts i—a 1b 2c 3q)0 “t[0]:(d;4f)"'typeq)ts i---d 1 \<= Did d get into the table?!b 2c 3Regards,PMOn Feb 16, 3:30?am, Simon Garland <si…> wrote:> you don’t provide an example> but I’d guess you overlooked:>> “?Now update messages from clients are logged?”>> from the link Tim sent>> using -l sets you up a server which has logging enabled for client messages> NOT for commands typed in at the console> try talking to your server from a client task, or for quick testing fooling> it by using the handle 0>> q)0"bb:17;aa:2 3+4 5 6”> rollback> 'length> q)bb> 'bb> q)aa> 'aa>> On 15 February 2011 23:15, petrum <petru.margin…> wrote:>> > I’ve tried it, but I cannot get it to automatically rollback, and get> > the initial table when the update fails.> > The original data is restored (from logs) only if I restart the q> > process.>></petru.margin…></si…>

PM

?

try…

?

q)0 “t[0]:(`d;4 i )”

?

i think you’re getting a 'type error because the list is “i->integer” and you’re using “f->floating”

Agreed.But the problem is not why I get the 'type error (this wasintentionally generated), but why the “s” column gets updated (gettingthe d in the first row).(please read the initial question in this thread, and the subject...)The expectation is that the update will rollback, and no column getsupdated.PMOn Feb 16, 12:34?pm, Louis Mercorelli <louis.mercore...>wrote:&gt; PM&gt;&gt; try...&gt;&gt; q)0 "t[0]:(d;4i)">> i think you’re getting a 'type error because the list is “i->integer” and> you’re using “f->floating”>> On Thu, Feb 17, 2011 at 1:01 AM, petrum <petru.margin…> wrote:> > Thanks for reply.> > Here is an example:>> > $> q test -l> > KDB+ 2.7 2010.12.06 Copyright (C) 1993-2010 Kx Systems> > …>> > q).z.f> > test&gt; &gt; q)t:([] s:abc; i:1 2 3)> > q)\l> > q)t> > s i> > —> > a 1> > b 2> > c 3> > q)0 “t[0]:(d;4f)"&gt; &gt; 'type&gt; &gt; q)t&gt; &gt; s i&gt; &gt; ---&gt; &gt; d 1 &lt;= Did d get into the table?!> > b 2> > c 3>> > Regards,> > PM>> > On Feb 16, 3:30 am, Simon Garland <si…> wrote:> > > you don’t provide an example> > > but I’d guess you overlooked:>> > > “?Now update messages from clients are logged?”>> > > from the link Tim sent>> > > using -l sets you up a server which has logging enabled for client> > messages> > > NOT for commands typed in at the console> > > try talking to your server from a client task, or for quick testing> > fooling> > > it by using the handle 0>> > > q)0"bb:17;aa:2 3+4 5 6”> > > rollback> > > 'length> > > q)bb> > > 'bb> > > q)aa> > > 'aa>> > ?> On 15 February 2011 23:15, petrum <petru.margin…> wrote:>> > > > I’ve tried it, but I cannot get it to automatically rollback, and get> > > > the initial table when the update fails.> > > > The original data is restored (from logs) only if I restart the q> > > > process.>> > –> >

Submitted via Google Groups</petru.margin…></si…></petru.margin…></louis.mercore…>

oops, my first post to a group. sorry for the mistake.

?

LRM

fixed in next release. Thanks for bringing it to our attention.

$q -l log

KDB+ 2.7 2011.02.16 …

q)0"t:( s:ab`c; i:1 2 3)"

q)0"t[0]:(`d;4f)"

rollback

'type

q)t

s i


a 1

b 2

c 3

btw, a new release is available as 2.7 2011.02.16

What’s the meaning of the ‘log’ parameter in the prev. example?It looks like the ‘log’ param has to be before the “-l” flag,otherwise it seems to be ignored:C:\q>w32\q.exe log -lKDB+ 2.7 2011.02.16 Copyright (C) 1993-2011 Kx Systemsw32/ …q).z.flogC:\q\>w32\q.exe -l logKDB+ 2.7 2011.02.16 Copyright (C) 1993-2011 Kx Systemsw32/ ...q).z.fRegards,PetruOn Feb 16, 3:46?pm, Charles Skelton <char…> wrote:> fixed in next release. Thanks for bringing it to our attention.>> $q -l log> KDB+ 2.7 2011.02.16 …>> q)0"t:( s:abc; i:1 2 3)"&gt; q)0"t[0]:(d;4f)“> rollback> 'type> q)t> s i> —> a 1> b 2> c 3>> On Wed, Feb 16, 2011 at 7:26 PM, petrum <petru.margin…> wrote:> > Agreed.>> > But the problem is not why I get the 'type error (this was> > intentionally generated), but why the “s” column gets updated (getting> > the d in the first row).&gt; &gt; (please read the initial question in this thread, and the subject...)&gt;&gt; &gt; The expectation is that the update will rollback, and no column gets&gt; &gt; updated.&gt;&gt; &gt; PM&gt;&gt; &gt; On Feb 16, 12:34 pm, Louis Mercorelli <louis.mercore...>&gt; &gt; wrote:&gt; &gt; &gt; PM&gt;&gt; &gt; &gt; try...&gt;&gt; &gt; &gt; q)0 "t[0]:(d;4i)”>> > > i think you’re getting a 'type error because the list is “i->integer” and> > > you’re using “f->floating”>> > > On Thu, Feb 17, 2011 at 1:01 AM, petrum <petru.margin…>> > wrote:> > > > Thanks for reply.> > > > Here is an example:>> > > > $> q test -l> > > > KDB+ 2.7 2010.12.06 Copyright (C) 1993-2010 Kx Systems> > > > …>> > > > q).z.f> > > > test&gt; &gt; &gt; &gt; q)t:([] s:abc; i:1 2 3)> > > > q)\l> > > > q)t> > > > s i> > > > —> > > > a 1> > > > b 2> > > > c 3> > > > q)0 “t[0]:(d;4f)"&gt; &gt; &gt; &gt; 'type&gt; &gt; &gt; &gt; q)t&gt; &gt; &gt; &gt; s i&gt; &gt; &gt; &gt; ---&gt; &gt; &gt; &gt; d 1 &lt;= Did d get into the table?!> > > > b 2> > > > c 3>> > > > Regards,> > > > PM>> > > > On Feb 16, 3:30 am, Simon Garland <si…> wrote:> > > > > you don’t provide an example> > > > > but I’d guess you overlooked:>> > > > > “?Now update messages from clients are logged?”>> > > > > from the link Tim sent>> > > > > using -l sets you up a server which has logging enabled for client> > > > messages> > > > > NOT for commands typed in at the console> > > > > try talking to your server from a client task, or for quick testing> > > > fooling> > > > > it by using the handle 0>> > > > > q)0"bb:17;aa:2 3+4 5 6”> > > > > rollback> > > > > 'length> > > > > q)bb> > > > > 'bb> > > > > q)aa> > > > > 'aa>> > > > ?> On 15 February 2011 23:15, petrum <petru.margin…>> > wrote:>> > > > > > I’ve tried it, but I cannot get it to automatically rollback, and> > get> > > > > > the initial table when the update fails.> > > > > > The original data is restored (from logs) only if I restart the q> > > > > > process.>> > > > –> > > > You received this message because you are subscribed to the Google> > Groups> > > > “Kdb+ Personal Developers” group.> > > > To post to this group, send email to personal-kdbplus@googlegroups.com> > .> > > > To unsubscribe from this group, send email to> > > > personal-kdbplus+unsubscribe@googlegroups.com.> > > > For more options, visit this group at> > > >http://groups.google.com/group/personal-kdbplus?hl=en.&gt;&gt; > –> >

Submitted via Google Groups</petru.margin…></si…></petru.margin…></louis.mercore…></petru.margin…></char…>

yes, typo.

sorry.

https://code.kx.com/trac/wiki/Cookbook/Logging