Re: [Spock Proxy Devel] Some spockproxy questions.
Status: Alpha
Brought to you by:
kaotao
From: Zach G. <za...@ii...> - 2008-08-05 18:07:47
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> On 7/29/2008 2:26 PM, Frank Flynn wrote: <blockquote cite="mid:5E9...@co..." type="cite"><br> On Jul 29, 2008, at 12:26 PM, Zach Garner wrote: <br> <br> <blockquote type="cite">I've got a question. I've been working on a configuration using spockproxy (which I'm really enjoying btw). So far I've got everything working pretty well, which is exciting. <br> <br> My question is, is there a way to return the incremented column value after performing an insert? Or to retrieve the value just before performing the insert? I'm working with an application that has been using an incrementing value in combination with the last_insert_id() function to track the data and continue making some changes to it. <br> </blockquote> <br> As Michael said the Spockproxy does not support the last_insert_id() but there is a function get_next_id which will give you one or several id for a particular table before you do the insert. Then you can use these id(s) and the proxy will not change them. <br> <br> Because it's called ahead of time nether the proxy nor the MySQL server could possibly know which table you're about to insert into so you have to tell it. You can also ask for several id's at once; if you know you have 50 rows to insert just ask for 50 id's and they will be put aside for you so you can just use them and not have to keep asking for new ones. <br> <br> The format is: <br> <br> select get_next_id( < table name >, < number of id's you want >); <br> <br> </blockquote> Thank you. I did end up replacing all the last_insert_id() call and since the get_next_id generates the sequence and returns the id immediately I think it actually works better.<br> <br> I'm still experimenting with the application (and still enjoying it a lot!) but hope to do some testing soon. :)<br> <br> I think I had a bit of a misunderstanding with the universal tables. I'd originally assumed that spock replicated writes/deletes/updates to each shard *itself* when using a universal table; but it's literally mysql replication with the configuration database a write master to the shards? And that makes sense now that I think about it.<br> <br> Anyhow thanks for the responses and (once again) for sharing such an interesting and well thought out implementation. I'm back to testing!<br> <blockquote cite="mid:5E9...@co..." type="cite">and it will return the first id; if you asked for 50 then the next 50 are yours, if you asked for 1 that one is yours. Be careful because there is no error checking if you go over the id's you were alloted. <br> <br> There is a bug it the current function, it is not thread safe and if you hit it massively from several clients you can get the same id back. This is fixed in the next release which we should be posting soon. If your still experimenting the current function is fine; if you're ramping up of stress testing you'll want the new one. <br> <br> <blockquote type="cite"><br> Anyway, I'll keep playing around. Chances are I've missed something fairly obvious. <br> <br> It's been a real pleasure using such a nicely thought out implementation like this. <br> <br> Regards! <br> <br> Zach <br> </blockquote> <br> Thanks, <br> <br> Frank <br> <a class="moz-txt-link-freetext" href="http://www.spock.com/frank">http://www.spock.com/frank</a> <br> <br> </blockquote> <br> <br> <div class="moz-signature">-- <br> <font ptsize="10" family="SANSSERIF" color="#004080" face="Verdana" lang="0" size="2">_______________________________________________________________________</font><br> <font ptsize="8" family="SANSSERIF" color="#000000" face="Arial" lang="0" size="1"><b><span style="color: rgb(0, 0, 160);">Zach Garner</span></b> <span style="color: rgb(128, 128, 192);">| </span> Sr. Systems Administrator / Product Analyst <span style="color: rgb(128, 128, 192);">|</span> iiON Corporation <span style="color: rgb(128, 128, 192);">|</span> <a style="color: rgb(0, 0, 160); text-decoration: none;" target="_blank" href="http://www.iion.com/">www.iion.com</a> <span style="color: rgb(128, 128, 192);">|</span> Office: 858-713-0450 x 20<br> <br> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br> <div style="color: rgb(0, 64, 128); text-align: justify; width: 570px;">This message (and any associated files) is intended only for the individual named and may contain information that is confidential, subject to copyright or constitutes a trade secret. If you are not the named addressee you are hereby notified that any dissemination, copying or distribution of this message, or files associated with this message, is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. Messages sent to and from us may be monitored. Any views or opinions presented are solely those of the author and do not necessarily represent those of iiON Corporation.</div> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- </font></div> </body> </html> |