Permalink
Browse files

sync with tokyotyrant-1.1.19.tar.gz

  • Loading branch information...
1 parent 58f432e commit 5398c3567dcf42aec1ed9958e49ff87d62d770fc @etrepum etrepum committed Apr 2, 2009
Showing with 129 additions and 44 deletions.
  1. +12 −0 ChangeLog
  2. +10 −10 configure
  3. +2 −2 configure.in
  4. +12 −3 doc/index.html
  5. +3 −3 ext/senatus.lua
  6. +13 −0 man/tcrdb.3
  7. +15 −1 tcrdb.c
  8. +6 −0 tcrdb.h
  9. +4 −0 tcrtest.c
  10. +4 −1 tculog.c
  11. +9 −4 ttserver.c
  12. +37 −18 ttutil.c
  13. +2 −2 ttutil.h
View
@@ -1,5 +1,17 @@
2009-03-14 Mikio Hirabayashi <mikio@users.sourceforge.net>
+ * tcrdb.c (tcrdbqrysearchget): the option for no update log was added.
+
+ * tcrdb.c (tcrdbqrysearchcount): new function.
+
+ * tculog.c (tcreplread): timeout mechanism was added.
+
+ * ttserver.c (do_repl): performance was improved.
+
+ - Release: 1.1.19
+
+2009-03-14 Mikio Hirabayashi <mikio@users.sourceforge.net>
+
* ttservctl: configuration was modified and update log is now disabled by default.
* ttutil.c (ttopensock, ttacceptsock): performance was improved.
View
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for tokyotyrant 1.1.18.
+# Generated by GNU Autoconf 2.61 for tokyotyrant 1.1.19.
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@@ -572,8 +572,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='tokyotyrant'
PACKAGE_TARNAME='tokyotyrant'
-PACKAGE_VERSION='1.1.18'
-PACKAGE_STRING='tokyotyrant 1.1.18'
+PACKAGE_VERSION='1.1.19'
+PACKAGE_STRING='tokyotyrant 1.1.19'
PACKAGE_BUGREPORT=''
# Factoring default headers for most tests.
@@ -1194,7 +1194,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures tokyotyrant 1.1.18 to adapt to many kinds of systems.
+\`configure' configures tokyotyrant 1.1.19 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1255,7 +1255,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of tokyotyrant 1.1.18:";;
+ short | recursive ) echo "Configuration of tokyotyrant 1.1.19:";;
esac
cat <<\_ACEOF
@@ -1349,7 +1349,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-tokyotyrant configure 1.1.18
+tokyotyrant configure 1.1.19
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1363,7 +1363,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by tokyotyrant $as_me 1.1.18, which was
+It was created by tokyotyrant $as_me 1.1.19, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -1719,7 +1719,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# Package information
MYLIBVER=3
-MYLIBREV=2
+MYLIBREV=3
MYPROTVER="0.9"
# Targets
@@ -5912,7 +5912,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by tokyotyrant $as_me 1.1.18, which was
+This file was extended by tokyotyrant $as_me 1.1.19, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -5955,7 +5955,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-tokyotyrant config.status 1.1.18
+tokyotyrant config.status 1.1.19
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
View
@@ -7,11 +7,11 @@
#================================================================
# Package name
-AC_INIT(tokyotyrant, 1.1.18)
+AC_INIT(tokyotyrant, 1.1.19)
# Package information
MYLIBVER=3
-MYLIBREV=2
+MYLIBREV=3
MYPROTVER="0.9"
# Targets
View
@@ -91,7 +91,6 @@
padding: 0.2em;
background-color: #ddddee;
border: 1px solid #bbbbcc;
- border-radius: 4px;
font-size: 95%;
}
li,dt,dd {
@@ -1081,6 +1080,14 @@ <h3 id="tcrdbapi_apitbl">API of the Table Extension</h3>
<dd>Because the object of the return value is created with the function `tcmapnew', it should be deleted with the function `tcmapdel' when it is no longer in use.</dd>
</dl>
+<p>The function `tcrdbqrysearchcount' is used in order to get the count of corresponding records of a query object.</p>
+
+<dl class="api">
+<dt><code>int tcrdbqrysearchcount(RDBQRY *<var>qry</var>);</code></dt>
+<dd>`<var>qry</var>' specifies the query object.</dd>
+<dd>The return value is the count of corresponding records or 0 on failure.</dd>
+</dl>
+
<h3 id="tcrdbapi_example">Example Code</h3>
<p>The following code is an example to use a remote database.</p>
@@ -2072,6 +2079,8 @@ <h3 id="tutorial_tuning">Tuning</h3>
<p>If huge number of clients access the server, make sure the limit number of file descriptors per process is cleared. By default on most systems, it is set as 1024. If so, use `<code>ulimit</code>' to clear it.</p>
+<p>In order to deal with rushing queries at the peak time of your service, replication combining the on-memory hash/tree database and the file hash/tree database is useful. The master server handles the on-memory database and it can come through rushing queries at the peak time. Though the on-memory database can not assure the data persistence, the slave of replication compensates the shortage by storing records in the file database.</p>
+
<h3 id="tutorial_luaext">Lua Extension</h3>
<p>If you want more complex database operations than existing ones, use the Lua extension. For example, prepare the following script and save it as "test.lua". There is a function "fibonacci" which returns the Fibonacci number of a number of the key.</p>
@@ -2188,7 +2197,7 @@ <h3 id="tutorial_http">Using HTTP Client</h3>
<h3 id="tutorial_expcache">Persistent but Expirable Cache</h3>
-<p>If you want to cache data like session information for your Web application but want to avoid data loss because of the server crash, using Tokyo Tyrant can be the solution, that is to say, "persistent" expirable cache. It requires the following preconditions.</p>
+<p>If you want to cache data like session information for your Web application but want to avoid data loss because of the server crash, using Tokyo Tyrant can be the solution, that is to say, "persistent" but expirable cache. It requires the following preconditions.</p>
<ul>
<li>The server must open a table database.</li>
@@ -2206,7 +2215,7 @@ <h3 id="tutorial_expcache">Persistent but Expirable Cache</h3>
table.insert(args, "out")
local res = _misc("search", args)
if not res then
- _log("expiration was failed")
+ _log("expiration was failed", 2)
end
end
</pre>
View
@@ -348,7 +348,7 @@ end
-- get status of a file
-function stat(key, value)
+function statfile(key, value)
local stat = _stat(key)
if not stat then
return nil
@@ -415,7 +415,7 @@ function expire()
table.insert(args, "out")
local res = _misc("search", args)
if not res then
- _log("expiration was failed")
+ _log("expiration was failed", 2)
end
end
@@ -428,7 +428,7 @@ function expire2()
table.insert(args, "out")
local res = _misc("search", args)
if not res then
- _log("expiration was failed")
+ _log("expiration was failed", 2)
end
end
View
@@ -1147,6 +1147,19 @@ The return value is a map object containing columns.
Because the object of the return value is created with the function `tcmapnew', it should be deleted with the function `tcmapdel' when it is no longer in use.
.RE
.RE
+.PP
+The function `tcrdbqrysearchcount' is used in order to get the count of corresponding records of a query object.
+.PP
+.RS
+.br
+\fBint tcrdbqrysearchcount(RDBQRY *\fIqry\fB);\fR
+.RS
+`\fIqry\fR' specifies the query object.
+.RE
+.RS
+The return value is the count of corresponding records or 0 on failure.
+.RE
+.RE
.SH SEE ALSO
.PP
View
16 tcrdb.c
@@ -1431,7 +1431,7 @@ TCLIST *tcrdbqrysearchget(RDBQRY *qry){
assert(qry);
TCLIST *args = tclistdup(qry->args);
tclistpush2(args, "get");
- TCLIST *rv = tcrdbmisc(qry->rdb, "search", 0, args);
+ TCLIST *rv = tcrdbmisc(qry->rdb, "search", RDBMONOULOG, args);
tclistdel(args);
return rv;
}
@@ -1447,5 +1447,19 @@ TCMAP *tcrdbqryrescols(TCLIST *res, int index){
}
+/* Get the count of corresponding records of a query object. */
+int tcrdbqrysearchcount(RDBQRY *qry){
+ assert(qry);
+ TCLIST *args = tclistdup(qry->args);
+ tclistpush2(args, "count");
+ TCLIST *rv = tcrdbmisc(qry->rdb, "search", RDBMONOULOG, args);
+ tclistdel(args);
+ if(!rv) return 0;
+ int count = tclistnum(rv) > 0 ? tcatoi(tclistval2(rv, 0)) : 0;
+ tclistdel(rv);
+ return count;
+}
+
+
// END OF FILE
View
@@ -671,6 +671,12 @@ TCLIST *tcrdbqrysearchget(RDBQRY *qry);
TCMAP *tcrdbqryrescols(TCLIST *res, int index);
+/* Get the count of corresponding records of a query object.
+ `qry' specifies the query object.
+ The return value is the count of corresponding records or 0 on failure. */
+int tcrdbqrysearchcount(RDBQRY *qry);
+
+
__TCRDB_CLINKAGEEND
#endif /* duplication check */
View
@@ -1341,6 +1341,10 @@ static int proctable(const char *host, int port, int cnum, int rnum){
}
tcmapdel(cols);
}
+ if(tclistnum(res) != tcrdbqrysearchcount(qry)){
+ eprint(rdb, "(validation)");
+ err = true;
+ }
tclistdel(res);
tcrdbqrydel(qry);
qry = tcrdbqrynew(rdb);
View
@@ -19,6 +19,7 @@
#include "myconf.h"
#define TCULAIOCBNUM 64 // number of AIO tasks
+#define TCREPLTIMEO 5.0 // timeout of the replication socket
/* private function prototypes */
@@ -69,8 +70,8 @@ void tculogdel(TCULOG *ulog){
/* Set AIO control of an update log object. */
bool tculogsetaio(TCULOG *ulog){
- assert(ulog);
#if defined(_SYS_LINUX_)
+ assert(ulog);
if(ulog->base || ulog->aiocbs) return false;
struct aiocb *aiocbs = tcmalloc(sizeof(*aiocbs) * TCULAIOCBNUM);
for(int i = 0; i < TCULAIOCBNUM; i++){
@@ -79,6 +80,7 @@ bool tculogsetaio(TCULOG *ulog){
ulog->aiocbs = aiocbs;
return true;
#else
+ assert(ulog);
return true;
#endif
}
@@ -965,6 +967,7 @@ const char *tcreplread(TCREPL *repl, int *sp, uint64_t *tsp, uint32_t *sidp){
assert(repl && sp && tsp);
int ocs = PTHREAD_CANCEL_DISABLE;
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &ocs);
+ ttsocksetlife(repl->sock, TCREPLTIMEO);
int c = ttsockgetc(repl->sock);
if(c == TCULMAGICNOP){
*sp = 0;
View
@@ -2015,6 +2015,7 @@ static void do_repl(TTSOCK *sock, TASKARG *arg, TTREQ *req){
if(ulrd){
pthread_cleanup_push((void (*)(void *))tculrddel, ulrd);
bool err = false;
+ bool idle = true;
const char *rbuf;
int rsiz;
uint64_t rts;
@@ -2023,13 +2024,17 @@ static void do_repl(TTSOCK *sock, TASKARG *arg, TTREQ *req){
while(!err && !ttserviskilled(g_serv)){
ttsocksetlife(sock, UINT_MAX);
req->mtime = tctime() + UINT_MAX;
- *(unsigned char *)stack = TCULMAGICNOP;
- if(!ttsocksend(sock, stack, sizeof(uint8_t))){
- err = true;
- ttservlog(g_serv, TTLOGINFO, "do_repl: connection closed");
+ if(idle){
+ *(unsigned char *)stack = TCULMAGICNOP;
+ if(!ttsocksend(sock, stack, sizeof(uint8_t))){
+ err = true;
+ ttservlog(g_serv, TTLOGINFO, "do_repl: connection closed");
+ }
}
tculrdwait(ulrd);
+ idle = true;
while(!err && (rbuf = tculrdread(ulrd, &rsiz, &rts, &rsid)) != NULL){
+ idle = false;
if(rsid == sid) continue;
int msiz = sizeof(uint8_t) + sizeof(uint64_t) + sizeof(uint32_t) * 2 + rsiz;
char *mbuf = (msiz < TTIOBUFSIZ) ? stack : tcmalloc(msiz);
Oops, something went wrong.

0 comments on commit 5398c35

Please sign in to comment.