Every repository with this icon (
Every repository with this icon (
| Description: | Beanstalk is a simple, fast work queue. edit |
-
1 comment Created 8 months ago by krfixedxcarefully allocate disk space for binlog recordskrxWe want to handle a full disk with grace.
Comments
-
See http://groups.google.com/group/beanstalk-talk/t/e589c79f86f4d0ac for the bug report.
Comments
-
Avoid stupid off-by-one errors at one-second granularity.
Comments
-
One of them breaks on Mac OS.
Comments
-
See http://groups.google.com/group/beanstalk-talk/t/8210428dd5f2c98f for details.
Comments
-
Currently, if a client reserves a job and then crashes, the job will be put in the ready queue with no indication that it had ever been reserved. This is not good; clients should be able to distinguish such a job from one that has never been reserved.
So we should add a "reserves" counter and/or increment the "timeouts" counter in this situation and/or introduce a separate counter just for this situation.
See http://groups.google.com/group/beanstalk-talk/t/951b6c35752257a4 for more info.
Comments
-
Currently the peek commands do a job_copy() before calling reply_job() presumably to avoid a race between the job being sent back to the client, and it being DELETEd by another client.
reset_conn() should free the job copy however it currently requires the job.id to be 0 before it will call job_free(). This works fine for the h_conn_timeout() case as in http://github.com/kr/beanstalkd/commit/d77814816f54c48b7bcc85c36bb681fd277d3e65 but it overloads the meaning of job.id which is an essential part of the peek responses.
The result is that we can't set a copied job.id to 0 for peek responses which means it won't get freed by reset_conn(), leading to a fast memory leak if any of the peek commands are used.
I'll submit a patch which adds a new job state to mark a job as copied (JOB_STATE_COPY) but I'm not sure if its the best way to solve this.
http://gist.github.com/139279 will hammer peek-buried sufficiently that you'll see the beanstalkd process size grow very rapidly.
Comments
Thanks for finding this and for the patch. I'm reviewing it now.
-
1 comment Created 4 months ago by krAllow beanstalkd to reserve arbitrary amounts of binlog spacefixedxCurrently it can only create one extra binlog file on disk. After that it will deny operations that want to reserve space. (Search for "overextended" in binlog.c.) There just needs to be a linked list of future binlog files; currently there is a pointer to (up to) one future file. In practice this only happens when the queue holds more than about 10 MB of jobs.
Comments
-
Should have optional throttling. There should be three modes: always fsync (for best reliability), fsync at most once every N seconds, or never fsync (best performance).
Could be controlled by two options: "-s 0" for always fsync, "-s N" for sync at most once every N seconds, and "-S" for never fsync.
Comments
-
beanstalkd only handles SIGINT and does then a clean shutdown. The following patch adds this behavior for SIGTERM. Tested against version 1.3
Patch:
--- beanstalkd.c.orig 2009-08-15 13:48:46.000000000 +0200 +++ beanstalkd.c 2009-08-15 13:49:11.000000000 +0200 @@ -120,6 +120,10 @@ sa.sa_handler = exit_cleanly; r = sigaction(SIGINT, &sa, 0); if (r == -1) twarn("sigaction(SIGINT)"), exit(111); + + sa.sa_handler = exit_cleanly; + r = sigaction(SIGTERM, &sa, 0); + if (r == -1) twarn("sigaction(SIGTERM)"), exit(111); } /* This is a workaround for a mystifying workaround in libevent's epollComments
-
9 comments Created 2 months ago by topfunkyBuild error on Snow Leopard: fdatasyncfixedxI get a build error on Mac OS X Snow Leopard where it says it can't find fdatasync.
Output of ./configure:
https://gist.github.com/0290aa815842b888eed4Error upon running make:
cc1: warnings being treated as errors binlog.c: In function ‘binlog_write_job’: binlog.c:491: warning: implicit declaration of function ‘fdatasync’ make[1]: *** [binlog.o] Error 1 make: *** [all] Error 2Using libevent-1.4.12-stable ("make verify" passed).
Comments
To clarify: This was while building beanstalkd-1.4 stable release from http://kr.github.com/beanstalkd/download.html
I worked around this issue by removing the following from config.h after running ./configure, before running make.
/* Define to 1 if you have the `fdatasync' function. */ #define HAVE_FDATASYNC 0Hopefully the real solution is clear to someone :)
Does snow leopard have a man page for fdatasync? Can anyone post or send me the #include lines from the man page?
I get nothing for "man fdatasync" and a Google search appears to say that it's not available on any flavor of Mac OS X.
I couldn't find it in /usr/include/unistd.h or /usr/include/sys/unistd.h
I'm confused by the line in your configure transcript that says:
checking for fdatasync... yesThat indicates that such a function is defined somewhere in your system's header files. I think a vanilla installation of 10.6 (and for sure 10.5) doesn't have fdatasync anywhere.
The build is also getting confused; configure thinks fdatasync is defined somewhere, but then gcc doesn't have a prototype for it, hence the error message.
I can confirm this as well. The only reference to fdatasync in /usr/include is in:
include/sys/syscall.h 227:#define SYS_fdatasync 187On my system, setting HAVE_FDATASYNC to 0 in config.h still results in a failed build:
gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -Werror -I/sw/local/include -c -o beanstalkd.o beanstalkd.c gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -Werror -I/sw/local/include -c -o binlog.o binlog.c cc1: warnings being treated as errors binlog.c: In function ‘binlog_write_job’: binlog.c:491: warning: implicit declaration of function ‘fdatasync’ make[1]: *** [binlog.o] Error 1 make: *** [all] Error 2Edit: Of course - removing HAVE_FDATASYNC works. Thanks, mattyoho -- serves me for not doing anything in C for a long while.
robotadam: "On my system, setting HAVE_FDATASYNC to 0 in config.h still results in a failed build:"
This was true for me as well. I commented the def out instead, cleaned and ran make again and was then able to install successfully.
copiousfreetime
Sun Oct 11 14:56:20 -0700 2009
| link
autoconf does not check this existence correctly. I believe I have fixed this.
-
reeler% git clone git://github.com/kr/beanstalkd.git
reeler% cd beanstalkd
reeler% ./autogen.sh
configure.in:10: installing./install-sh'<br/> configure.in:10: installing./missing'
reeler% ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... none
checking for supported compiler flags... -Wall -Werror
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) none
checking for a BSD-compatible install... /usr/bin/install -c
checking if compiler supports -R... yes
checking libevent install prefix... /usr/local
checking for posix_fallocate... no
checking for fdatasync... no
checking for bind in -lsocket... no
checking for inet_aton in -lnsl... no
checking for event_get_version in -levent... yes
checking for event_reinit in -levent... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for uint16_t... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating beanstalkd.spec
config.status: creating config.h
config.status: executing depfiles commands
reeler% make
make all-am
gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -Werror -I/usr/local/include -c -o beanstalkd.o beanstalkd.c
gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -Werror -I/usr/local/include -c -o binlog.o binlog.c
gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -Werror -I/usr/local/include -c -o conn.o conn.c
gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -Werror -I/usr/local/include -c -o job.o job.c
gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -Werror -I/usr/local/include -c -o ms.o ms.c
gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -Werror -I/usr/local/include -c -o net.o net.c
In file included from net.h:22,
from net.c:22:/usr/include/netinet/tcp.h:40: error: expected '=', ',', ';', 'asm' or 'attribute' before 'tcp_seq' /usr/include/netinet/tcp.h:50: error: expected specifier-qualifier-list before 'u_short' /usr/include/netinet/tcp.h:175: error: expected specifier-qualifier-list before 'u_int8_t' *** Error code 1
Stop in /usr/home/peter/beanstalkd.
*** Error code 1Stop in /usr/home/peter/beanstalkd.
reeler%
Comments
I found a fix for this. Simply put #include <sys/types.h> under #include <sys/socket.h> in the beanstalkd source file: net.h
Fix build on FreeBSD.
Thanks to Peter Kieltyka http://github.com/pkieltyka for the fix.
Closed by 24aa767. -
1 comment Created 8 days ago by joelbohrerpeek buried seems to have a problemnot a bugxHi,
I'm using beanstalkd 1.4.3 with PHP, and I found a little problem. The "peek-buried" command seems to be broken
Here are my commands :watch test
WATCHING 2stats-tube test
OK 248
name: test
current-jobs-urgent: 0
current-jobs-ready: 0
current-jobs-reserved: 0
current-jobs-delayed: 0
current-jobs-buried: 4
total-jobs: 4
current-using: 0
current-watching: 1
current-waiting: 0
cmd-pause-tube: 0
pause: 0
pause-time-left: 0list-tubes-watched
OK 21
default
testpeek-buried
NOT_FOUNDSo, I have some buried jobs in my queue, but peek-buried don't find them...
Joël
Comments
-
Can be used, e.g., for deduplication of work.
Comments
+1 I saw that in the roadmap, and know exactly what I'd use it for.
What would be the difference between this and the existing job ids? If we're suggesting features I'd love deleting or re-prioritising jobs by id - related?
You have no control of existing job ids. The idea is to be able to assign job ids on the client. This way, multiple (distributed) clients could interact (reschedule, cancel, pop, etc) the same job.
You can already delete any job by id. The only exception: you cannot delete a job some other client currently has reserved.
Re-prioritising jobs is a nice idea. Feel free to open a ticket for it.
kr, you can delete by ID, but it assumes I know the id. I want the following scenario: client A queues new job (name: job1), client B, which knows nothing about client A, reaches in and modifies the payload / time to run / etc for job1. To accomplish this, the name has to depend on some external knowledge (not beanstalkd assigning job ids). For example.. let the job id be an email of the user, or a qualified url, etc.
Got it. That's exactly what this ticket is for.
I should try to be more clear about who I'm replying to. Sorry about that.
Ok now I understand the motivation for this feature, and it's another +1 from me. Definitely opens up useful possibilities. I'll open another ticket for reprioritizing jobs.
-
This falls outside the main scope of beanstalkd's purpose, but I think it opens up a lot of interesting possibilities.
Such tubes can be marked as special by prefixing the name with a special char. I think "~" would work fine as that char.
Comments
-
0 comments Created 5 months ago by pdaClient disconnect shouldn't auto-release reserved job onto front of queue.featurexCurrently when a client disconnects while it has a reserved job, that job is instantly released onto the front of the queue, without respect of its remaining TTR.
This means that:
- A worker executing long jobs cannot disconnect/reconnect to beanstalkd during execution. Perhaps that would make it too hard to track which client owns which job reservation though...
- A job that causes a worker to crash constantly hogs the front of the queue, blocking subsequent jobs from coming through.
Perhaps auto-release due to disconnect should at least release onto the end of the queue, at a lower priority, or with a delay..?
Comments
-
It would be nice to have a client that just forwards jobs from one beanstalkd instance to another. See http://groups.google.com/group/beanstalk-talk/t/984bfc8037847e53 for some motivation for this setup.
Comments
-
0 comments Created 4 months ago by krMake binlog format robust against errors.featurexProbably just means adding a CRC to stored records.
Comments
-
When submitting jobs around 2MB, beanstalkd gets really slow. See here for the original report:
http://groups.google.com/group/beanstalk-talk/t/f27bd53d62d23f0c
Comments
-
Given a job id, I would like to be able to reprioritize it. Currently I can only achieve this by calling peek, delete, then recreating the job.
One possibility would be to allow release to be called without first having reserved the job. Currently the interface for delete and release is inconsistent:
put 0 0 60 3 foo INSERTED 1 delete 1 DELETED put 0 0 60 3 bar INSERTED 2 release 2 100 0 NOT_FOUND delete 2 DELETEDComments
-
4 comments Created 2 months ago by pkieltykaBroken pipe error and heavy CPU use with misbehaving clientsbugx| See below... This happens when clients send reserve | commands constantly on an empty queue.
I'm running the master beanstalkd on Snow Leopard and it's been working well, except I've come across the error:
./beanstalkd: prot.c:672 in check_err: writev(): Broken pipe ./beanstalkd: prot.c:672 in check_err: writev(): Broken pipe ..
Without the clients doing anything else to the queue, this causes beanstalkd to run at 97% CPU usage. I'm not sure what caused this specifically but it occurs when I have one client adding things onto the queue and another removing them (about 10 items per second).
Cheers
Peter
Comments
Another thing is I noticed that beanstalkd's memory usage increases slowly and never releases it's allocated memory. Perhaps I'm doing something wrong or its my environment, but I'm interested to know the expected behaviour. By the way, I am using a persistent queue via the binlog.
Something is wrong if it takes 97% cpu with so little activity. I will try to reproduce it.
I looked into this some more and it results from my client code doing crazy things, it was sending "reserve" commands in an infinite loop without any jobs on the queue. I've fixed my code since then and it's been working great.
Perhaps though, you could ignore subsequent reserve commands for a particular connection .. or something.
Thx.
-
0 comments Created 2 months ago by krfeaturexaccept LF in addition to CR LF to terminate commandskrxComments
-
2 comments Created about 1 month ago by krfeaturexadd underscore "_" to list of valid tube name characterskrx -
Our jankity shell scripts don't work with all versions of netcat. It's just too hard to use reliably.
I'm leaning toward a really simple, custom python framework. But if there are any really good protocol testing tools out there, I'd love to know.
Comments
-
3 comments Created 11 days ago by thijsterlouwSequence numbers / Synchronous clients?featurexI just read the protocol discription for Beanstalkd. The project looks great and the protocol is really simple. Should be very straightforward to implement in a language such as Erlang. The only problem I could see is the lack of sequence numbers. This basically would force synchronous usage for the clients of Beanstalkd ? Do you have any plans for a binary protocol with sequence numbers?
Comments
thijsterlouw
Mon Dec 07 08:18:12 -0800 2009
| link
If the responses always arrive in the same order of the requests (fifo), then sending/receiving async using a queue should also be a viable option?
Nonetheless, a binary protocol like memcached would also be great :)
There was discussion of a binary protocol back when beanstalkd was still young, but nothing came of it. I think it would be easier to revisit now that the text protocol changes so rarely.
And yes, you can use the existing protocol asynchronously, but you have to keep track of the order of commands you sent and responses you expect. In particular, you can send many commands before reading the replies (aka pipelining).
There is an Erlang client library at http://github.com/tim/erlang-beanstalk ; perhaps that will be illustrative. At some point I'd like to make a proof-of-concept in node.js as well.
thijsterlouw
Thu Dec 10 17:34:26 -0800 2009
| link
thanks for the reply. I looked at that erlang-beanstalk client, but it's implementation is too simple for our purposes: Tim uses a (blocking) gen_tcp:send/recv combination, which means that each tcp connection (server process) can only handle one request. When you have many hundreds of requests coming quickly, this design will easily lead to timeouts in the gen_server:call(). Thus it is unsuitable for high request rates. Using async with seq. numbers is the easiest approach, but we will probably use pipelining instead for our client.












Allocate disk space more carefully. Closed by 12299e0.