Zope Subversion Repository

  Zope

Zope: ZODB/trunk/src/ZEO/zrpc/connection.py


No default branch

Revision 123454 - (view) (download) (as text) - [select for diffs]
Modified Mon Nov 21 12:33:31 2011 UTC (2 months, 2 weeks ago) by jim
File length: 31992 byte(s)
Diff to previous 121391
- Storage servers now emit Serving and Closed events so subscribers
  can discover addresses when dynamic port assignment (bind to port 0)
  is used. This could, for example, be used to update address
  information in a ZooKeeper database.

- Client storagers have a method, new_addr, that can be used to change
  the server address(es). This can be used, for example, to update a
  dynamically determined server address from information in a
  ZooKeeper database.

- Moved some responsibility from runzeo to StorageServer to make it
  easier to use storage servers without runzeo.

Revision 121391 - (view) (download) (as text) - [select for diffs]
Modified Mon Apr 11 21:12:27 2011 UTC (9 months, 4 weeks ago) by jim
File length: 31870 byte(s)
Diff to previous 121306
Lots of code cleanups.

https://bugs.launchpad.net/zodb/+bug/677751

Revision 121306 - (view) (download) (as text) - [select for diffs]
Modified Wed Apr 6 14:23:24 2011 UTC (10 months ago) by jim
File length: 31950 byte(s)
Diff to previous 116175
Provide shorter code path for loads, which are most common operation.

Simplified and optimized marshalling code.

Revision 116175 - (view) (download) (as text) - [select for diffs]
Modified Fri Sep 3 13:56:12 2010 UTC (17 months ago) by jim
File length: 30737 byte(s)
Diff to previous 116172
Updated ZEO protocol version to reflect addition of
checkCurrentSerialInTransaction.

Add logic to allow new clients to be used with older servers.

Revision 116172 - (view) (download) (as text) - [select for diffs]
Modified Thu Sep 2 22:30:24 2010 UTC (17 months, 1 week ago) by jim
File length: 30693 byte(s)
Diff to previous 113734
Updated comment for server protocol.

Revision 113734 - (view) (download) (as text) - [select for diffs]
Modified Mon Jun 21 15:33:46 2010 UTC (19 months, 2 weeks ago) by ctheune
File length: 30667 byte(s)
Diff to previous 111922
Comply with repository policy.

Revision 111922 - (view) (download) (as text) - [select for diffs]
Modified Tue May 4 14:41:32 2010 UTC (21 months, 1 week ago) by jim
File length: 30668 byte(s)
Diff to previous 108740
Gave delay objects a repr for debugging purposes.

Revision 108740 - (view) (download) (as text) - [select for diffs]
Modified Wed Feb 3 22:09:56 2010 UTC (2 years ago) by jim
File length: 30434 byte(s)
Diff to previous 108694
Fixed a threading bug.

Revision 108694 - (view) (download) (as text) - [select for diffs]
Modified Mon Feb 1 19:12:15 2010 UTC (2 years ago) by jim
File length: 30061 byte(s)
Diff to previous 108679
The storage server is now multi-threaded.

Revision 108679 - (view) (download) (as text) - [select for diffs]
Modified Sun Jan 31 19:59:54 2010 UTC (2 years ago) by jim
File length: 29993 byte(s)
Diff to previous 108653
Refactored storage server to support multiple client threads.

Changed ZEO undo protocol. (Undo is disabled with older clients.)
Now use one-way undoa.  Undone oids are now returned by (tpc_)vote for
ZEO. Undo no-longer gets commit lock.

Revision 108653 - (view) (download) (as text) - [select for diffs]
Modified Fri Jan 29 22:47:22 2010 UTC (2 years ago) by jim
File length: 29535 byte(s)
Diff to previous 108624
ZEO clients (``ClientStorage`` instances) now work in forked processes,
including those created via ``multiprocessing.Process`` instances.

This entailed giving each client storage it's own networking thread.

Revision 108624 - (view) (download) (as text) - [select for diffs]
Modified Thu Jan 28 21:49:34 2010 UTC (2 years ago) by jim
File length: 33927 byte(s)
Diff to previous 106764
Refactored the zrpc implementation to:

- Most server methods now return data to clients more quickly by writing to
  client sockets immediately, rather than waiting for the asyncore
  select loop to get around to it.

- More clearly define client and server responsibilities. Machinery
  needed for just clients or just servers has been moved to the
  corresponding connection subclasses.

- Degeneralized "flags" argument to many methods. There's just one
  async flag.

Revision 106764 - (view) (download) (as text) - [select for diffs]
Modified Fri Dec 18 19:54:33 2009 UTC (2 years, 1 month ago) by jim
File length: 34134 byte(s)
Diff to previous 106151
Turn off debug logging. It's waaaay too expensive. But make it not too
hard to turn back on when it's needed, although, at that poiint, it
still might not be enough. :)

Revision 106151 - (view) (download) (as text) - [select for diffs]
Modified Tue Dec 1 22:24:48 2009 UTC (2 years, 2 months ago) by jim
File length: 34103 byte(s)
Diff to previous 104950
Merged the chrisw-error_logging branch:

Bug fixed:
- Internal ZEO errors were logged at the INFO level, rather
  than at the error level.

Revision 104950 - (view) (download) (as text) - [select for diffs]
Modified Thu Oct 8 18:30:11 2009 UTC (2 years, 4 months ago) by jim
File length: 34102 byte(s)
Diff to previous 104949
Fixed atexit handler to deal with the possibility that the ex

Revision 104949 - (view) (download) (as text) - [select for diffs]
Modified Thu Oct 8 17:50:10 2009 UTC (2 years, 4 months ago) by jim
File length: 34066 byte(s)
Diff to previous 102753
Bug Fixed:
  ZEO manages a separate thread for client network IO.  It created
  this thread on import, which caused problems for applications that
  implemented daemon behavior by forking.  Now, the client thread
  isn't created until needed.

Revision 102753 - (view) (download) (as text) - [select for diffs]
Modified Thu Aug 13 22:15:14 2009 UTC (2 years, 5 months ago) by jim
File length: 33788 byte(s)
Diff to previous 101410
Bugs Fixed:

- Fixed vulnerabilities in the ZEO network protocol that allow:

CVE-2009-0668 Arbitrary Python code execution in ZODB ZEO storage servers
  CVE-2009-0669 Authentication bypass in ZODB ZEO storage servers

- Limit the number of object ids that can be allocated at once to
  avoid running out of memory.

Revision 101410 - (view) (download) (as text) - [select for diffs]
Modified Thu Jul 2 20:55:40 2009 UTC (2 years, 7 months ago) by jim
File length: 33728 byte(s)
Diff to previous 94170
Bugs Fixed
----------

- ZEO client threads were unnamed, making it hard to debug thread
  management.

Revision 94170 - (view) (download) (as text) - [select for diffs]
Modified Thu Dec 18 14:45:10 2008 UTC (3 years, 1 month ago) by jim
File length: 33787 byte(s)
Diff to previous 93355
POSKeyErrors are really client errors

Revision 93355 - (view) (download) (as text) - [select for diffs]
Modified Tue Nov 25 23:54:19 2008 UTC (3 years, 2 months ago) by jim
File length: 33488 byte(s)
Diff to previous 92918
Cleaned up the Z309 ZEO protocol, removing versions from arguments and
return values.  This in turn simplified the client and server
software.

Added code to select different client and server stubs and input
handlers depening on whether the Z309 or earlier protocols are used.

ZODB 3.8 clients can now talk to ZODB 3.9 servers and the other way
around.

Revision 92918 - (view) (download) (as text) - [select for diffs]
Modified Thu Nov 13 23:44:57 2008 UTC (3 years, 2 months ago) by jim
File length: 33453 byte(s)
Diff to previous 90901
Upped the protocol number, since new server methods were added.

Revision 90901 - (view) (download) (as text) - [select for diffs]
Modified Fri Sep 5 19:34:25 2008 UTC (3 years, 5 months ago) by jim
File length: 33242 byte(s)
Diff to previous 90876
Fixed a possible problem with management of server connection
triggers.  Now that server triggers are shared, it makes no sense to
close them.  It's possible that the old logic in _pull_trigger got
around the potential problem intriduced when I made the server trigger
shared. I can't think of a good reason, otherwise, why tests weren't
failing.

Getting rid of close trigger simplified the code a bit. Also factored
some common close behavior, allowing me to get rid of an override.

Revision 90876 - (view) (download) (as text) - [select for diffs]
Modified Fri Sep 5 17:28:25 2008 UTC (3 years, 5 months ago) by jim
File length: 34140 byte(s)
Diff to previous 90583
Refactored cache verification to fix threading bugs during connection.

Changed connections to work with unset (None) clients.  Messages
aren't forwarded until the client is set.  This is to prevent sending
spurious invalidation messages until a client is ready to recieve them.

Revision 90583 - (view) (download) (as text) - [select for diffs]
Modified Fri Aug 29 12:44:34 2008 UTC (3 years, 5 months ago) by jim
File length: 34017 byte(s)
Diff to previous 90578
Bug Fixed: Improved the the ZEO client shutdown support to try to
avoid spurious errors on exit, especially for scripts, such as zeopack.

Revision 90578 - (view) (download) (as text) - [select for diffs]
Modified Fri Aug 29 12:29:51 2008 UTC (3 years, 5 months ago) by jim
File length: 33477 byte(s)
Diff to previous 84524
Fixed a trigger leak, introduced when I removed ThreadedAsync, that
caused an unneeded trigger to be created for each client
connection. This caused tests hang due to running out of file handles.

Let all server connections share a single trigger to avoid using too
many file handles in the server.

Revision 84524 - (view) (download) (as text) - [select for diffs]
Modified Fri Mar 7 08:20:48 2008 UTC (3 years, 11 months ago) by ctheune
File length: 33408 byte(s)
Diff to previous 84017
Fixed typo.

Revision 84017 - (view) (download) (as text) - [select for diffs]
Modified Mon Feb 18 11:32:30 2008 UTC (3 years, 11 months ago) by jim
File length: 33407 byte(s)
Diff to previous 79950
Removed ThreadedAsync and (last?) vestiges of the old "non-async"
mode.

Revision 79950 - (view) (download) (as text) - [select for diffs]
Modified Mon Sep 24 22:50:00 2007 UTC (4 years, 4 months ago) by jim
File length: 36918 byte(s)
Diff to previous 77055
Fixed a serious bug that could cause client I/O to stop
(hang). This was accomonied by a critical log message along the
lines of: "RuntimeError: dictionary changed size during iteration".

Revision 77055 - (view) (download) (as text) - [select for diffs]
Modified Mon Jun 25 15:19:07 2007 UTC (4 years, 7 months ago) by jim
File length: 36740 byte(s)
Diff to previous 76582
Updated to reflect differences in exception meta types ebtween Python
2.4 and 2.5.

Revision 76582 - (view) (download) (as text) - [select for diffs]
Modified Sun Jun 10 15:36:53 2007 UTC (4 years, 8 months ago) by jim
File length: 36741 byte(s)
Diff to previous 76510
Now require Blob files to be stored even for unopened blobs.

Revision 76510 - (view) (download) (as text) - [select for diffs]
Modified Fri Jun 8 15:57:36 2007 UTC (4 years, 8 months ago) by ctheune
File length: 36774 byte(s)
Diff to previous 75839
 - fixed typos

Revision 75839 - (view) (download) (as text) - [select for diffs]
Modified Fri May 18 18:02:05 2007 UTC (4 years, 8 months ago) by jim
File length: 36774 byte(s)
Diff to previous 73871
Added support for message iterators.  This allows one, for example, to
use an iterator to send a large file without loading it in memory.

Updated the ZEO protocol to reflect the new Blob-support methods.

Revision 73871 - (view) (download) (as text) - [select for diffs]
Modified Wed Mar 28 23:03:51 2007 UTC (4 years, 10 months ago) by jim
File length: 35502 byte(s)
Diff to previous 72630
Removed a needless timeout to a condition wait call. Using timeouts
can cause signidficant delays, especially on systems with very
course-grained sleeps, like most linux systems.  This change makes the
ZEO tests run about 25% faster on an Ubuntu desktop system.  We
suspect the production impact to be much greater, at least on some
systems.

Removed some non-async code, now that we no-longer have a non-async
mode. (I cowardly left an assert behind to make sure.:)

Revision 72630 - (view) (download) (as text) - [select for diffs]
Modified Thu Feb 15 20:09:36 2007 UTC (4 years, 11 months ago) by jim
File length: 36145 byte(s)
Diff to previous 69195
Added logic to avoid spurious errors from the logging system on exit.

Revision 69195 - (view) (download) (as text) - [select for diffs]
Modified Tue Jul 18 22:38:44 2006 UTC (5 years, 6 months ago) by jim
File length: 35845 byte(s)
Diff to previous 69179
Tried to make management of the client loop more robust and added a
test for it.

Revision 69179 - (view) (download) (as text) - [select for diffs]
Modified Tue Jul 18 18:15:57 2006 UTC (5 years, 6 months ago) by jim
File length: 35432 byte(s)
Diff to previous 38749
Removed the "sync" mode for ClientStorage.  Previously, a
ClientStorage could be in either "sync" mode or "async" mode.  Now
there is just "async" mode.  There is now a dedicicated asyncore main
loop dedicated to ZEO clients.

This addresses a test failure on Mac OS X,
http://www.zope.org/Collectors/Zope3-dev/650, that I believe was due
to a bug in sync mode. Some asyncore-based code was being called from
multiple threads that didn't expect to be.

Converting to always-async mode revealed some bugs that weren't caught
before because the tests ran in sync mode.  These problems could
explain some problems we've seen at times with clients taking a long
time to reconnect after a disconnect.

Added a partial heart beat to try to detect lost connections that
aren't otherwise caught,
http://mail.zope.org/pipermail/zodb-dev/2005-June/008951.html, by
perioidically writing to all connections during periods of inactivity.

Revision 38749 - (view) (download) (as text) - [select for diffs]
Modified Tue Oct 4 17:38:28 2005 UTC (6 years, 4 months ago) by tim_one
File length: 33006 byte(s)
Diff to previous 29770
Merge rev 38747 from 3.4 branch.

Port from 2.7 branch.

Collector 1900.

send_reply(), return_error():  Stop trying to catch an exception that doesn't
exist, when marshal.encode() raises an exception.  Jeremy simplified the
marshal.encode() half of this about 3 years ago, but apparently forgot to
change ZEO/zrpc/connection.py to match.

Revision 29770 - (view) (download) (as text) - [select for diffs]
Modified Fri Apr 1 03:05:06 2005 UTC (6 years, 10 months ago) by tim_one
File length: 32526 byte(s)
Diff to previous 29446
Merge rev 29769 from 3.3 branch.

Rewrite ZEO protocol negotiation.

3.3 should have bumped the ZEO protocol number (new methods were
added for MVCC support), but didn't.  Untangling this is a mess.

Revision 29446 - (view) (download) (as text) - [select for diffs]
Modified Fri Mar 11 22:07:51 2005 UTC (6 years, 11 months ago) by tim_one
File length: 30505 byte(s)
Diff to previous 29093
Convert some XXXs.  More to come.

Revision 29093 - (view) (download) (as text) - [select for diffs]
Modified Wed Feb 9 21:50:26 2005 UTC (7 years ago) by tim_one
File length: 30508 byte(s)
Diff to previous 29053
Port rev 29092 from 3.3 branch.

Forward port from ZODB 3.2.

Connection.__init__():  Python 2.4 added a new gimmick to asyncore (a
._map attribute on asyncore.dispatcher instances) that breaks the
delicate ZEO startup dance.  Repaired that.

Revision 29053 - (view) (download) (as text) - [select for diffs]
Modified Sat Feb 5 00:58:43 2005 UTC (7 years ago) by tim_one
File length: 29736 byte(s)
Diff to previous 25186
Merge rev 29052 from 3.3 branch.

Port from ZODB 3.2.

Fixed several thread and asyncore races in ZEO's connection dance.

ZEO/tests/ConnectionTests.py
    The pollUp() and pollDown() methods were pure busy loops whenever
    the asyncore socket map was empty, and at least on some flavors of
    Linux that starved the other thread(s) trying to do real work.
    This grossly increased the time needed to run tests using these, and
    sometimes caused bogus "timed out" test failures.

ZEO/zrpc/client.py
ZEO/zrpc/connection.py
    Renamed class ManagedConnection to ManagedClientConnection, for clarity.

    Moved the comment block about protocol negotiation from the guts of
    ManagedClientConnection to before the Connection base class -- the
    Connection constructor can't be understood without this context.  Added
    more words about the delicate protocol negotiation dance.

    Connection class:  made this an abstract base clase.  Derived classes
    _must_ implement the handshake() method.  There was really nothing in
    common between server and client wrt what handshake() needs to do, and
    it was confusing for one of them to use the base class handshake() while
    the other replaced handshake() completely.

    Connection.__init__:  It isn't safe to register with asyncore's socket
    map before special-casing for the first (protocol handshake) message is
    set up.  Repaired that.  Also removed the pointless "optionalness" of
    the optional arguments.

    ManagedClientConnection.__init__:  Added machinery to set up correct
    (thread-safe) message queueing.  There was an unrepairable hole before,
    in the transition between "I'm queueing msgs waiting for the server
    handshake" and "I'm done queueing messages":  it was impossible to know
    whether any calls to the client's "queue a message" method were in
    progress (in other threads), so impossible to make the transition safely
    in all cases.  The client had to grow its own message_output() method,
    with a mutex protecting the transition from thread races.

    Changed zrpc-conn log messages to include "(S)" for server-side or
    "(C)" for client-side.  This is especially helpful for figuring out
    logs produced while running the test suite (the server and client
    log messages end up in the same file then).

Revision 25186 - (view) (download) (as text) - [select for diffs]
Modified Wed Jun 2 15:07:33 2004 UTC (7 years, 8 months ago) by jim
File length: 24920 byte(s)
Diff to previous 24679
Updated license to version 2.1.

Revision 24679 - (view) (download) (as text) - [select for diffs]
Modified Fri May 14 19:12:33 2004 UTC (7 years, 8 months ago) by tim_one
File length: 24920 byte(s)
Diff to previous 3558
Expand svn Id keywords in .py, .c, and .h files.

Revision 3558 - (view) (download) (as text) - [select for diffs]
Modified Tue May 11 15:59:08 2004 UTC (7 years, 9 months ago) by root
File length: 24920 byte(s)
Diff to previous 3530
Set mime-type or svn-eol property from cvs expansion data

Revision 3530 - (view) (download) (as text) - [select for diffs]
Modified Sat Apr 24 20:40:44 2004 UTC (7 years, 9 months ago) by gintautasm
File length: 24920 byte(s)
Diff to previous 3342
Converted zRPC to use 'logging' instead of zLOG.

This probably broke the log analyzers... :(

Revision 3342 - (view) (download) (as text) - [select for diffs]
Modified Fri Feb 27 00:31:57 2004 UTC (7 years, 11 months ago) by faassen
File length: 24828 byte(s)
Diff to previous 3172
Remove unused imports.

Revision 3172 - (view) (download) (as text) - [select for diffs]
Modified Wed Dec 31 22:36:12 2003 UTC (8 years, 1 month ago) by jeremy
File length: 24858 byte(s)
Diff to previous 3066
Fix bug that prevented ZEO from working with Python 2.4.

Connection initialized _map as a dict containing a single entry
mapping the connection's fileno to the connection.  That was a misuse
of the _map variable, which is also used by the asyncore.dispatcher
base class to indicate whether the dispatcher users the default
socket_map or a custom socket_map.  A recent change to asyncore caused
it to use _map in its add_channel() and del_channel() methods, which
presumes to be a bug fix (may get ported to 2.3).  That causes our
dubious use of _map to be a problem, because we also put the
Connections in the global socket_map.  The new asyncore won't remove
it from the global socket map, because it has a custom _map.

Also change a bunch of 0/1s to False/Trues.

Revision 3066 - (view) (download) (as text) - [select for diffs]
Modified Thu Oct 2 18:17:31 2003 UTC (8 years, 4 months ago) by jeremy
File length: 24578 byte(s)
Diff to previous 3061
Merge changes from Zope-2_7-branch to the trunk.

Revision 3061 - (view) (download) (as text) - [select for diffs]
Modified Mon Sep 15 16:29:20 2003 UTC (8 years, 4 months ago) by jeremy
File length: 24389 byte(s)
Diff to previous 3003
Merge changes from ZODB3-3_2-branch to Zope-2_7-branch.

Please make all future changes on the Zope-2_7-branch instead.

Revision 3003 - (view) (download) (as text) - [select for diffs]
Modified Fri Jun 13 21:56:38 2003 UTC (8 years, 7 months ago) by jeremy
File length: 24381 byte(s)
Diff to previous 2980
Bacport various cache consistency bug fixes from the ZODB3-3_1-branch.

Revision 2980 - (view) (download) (as text) - [select for diffs]
Modified Fri May 30 19:20:57 2003 UTC (8 years, 8 months ago) by jeremy
File length: 24036 byte(s)
Diff to previous 2885
Merge ZODB3-auth-branch and bump a few version numbers.

After the merge, I made several Python 2.1 compatibility changes for
the auth code.

Revision 2885 - (view) (download) (as text) - [select for diffs]
Modified Thu Apr 24 22:04:27 2003 UTC (8 years, 9 months ago) by jeremy
File length: 23303 byte(s)
Diff to previous 2876
Add flush method.

Revision 2876 - (view) (download) (as text) - [select for diffs]
Modified Tue Apr 22 19:14:21 2003 UTC (8 years, 9 months ago) by jeremy
File length: 23112 byte(s)
Diff to previous 2748
Be prepared for a call that returns an empty tuple.

Revision 2748 - (view) (download) (as text) - [select for diffs]
Modified Fri Jan 24 14:32:44 2003 UTC (9 years ago) by gvanrossum
File length: 23092 byte(s)
Diff to previous 2690
Lower another log level ("recv reply: %s, %s, %s") at Florent
Guillaume's request.

Revision 2690 - (view) (download) (as text) - [select for diffs]
Modified Fri Jan 17 18:59:57 2003 UTC (9 years ago) by jeremy
File length: 23092 byte(s)
Diff to previous 2658
Lower to log levels, one at Toby's request.
Closes SF bug #659068.

Revision 2658 - (view) (download) (as text) - [select for diffs]
Modified Tue Jan 14 19:05:03 2003 UTC (9 years ago) by jeremy
File length: 23094 byte(s)
Diff to previous 2586
Rewrite pending() to handle input and output.

Pending does reads and writes.  In the case of server startup, we may
need to write out zeoVerify() messages.  Always check for read status,
but don't check for write status only there is output to do.  Only
continue in this loop as long as there is data to read.

Revision 2586 - (view) (download) (as text) - [select for diffs]
Modified Tue Jan 7 19:25:21 2003 UTC (9 years, 1 month ago) by jeremy
File length: 22035 byte(s)
Diff to previous 2568
Add _deferred_call() and _deferred_wait() for testing purposes.

XXX The deferred name isn't perfect, but async is already taken.

Revision 2568 - (view) (download) (as text) - [select for diffs]
Modified Fri Jan 3 22:07:45 2003 UTC (9 years, 1 month ago) by jeremy
File length: 21159 byte(s)
Diff to previous 2530
Merge ZODB3-fast-restart-branch to the trunk

Revision 2530 - (view) (download) (as text) - [select for diffs]
Modified Fri Dec 13 22:03:28 2002 UTC (9 years, 1 month ago) by jeremy
File length: 17436 byte(s)
Diff to previous 2397
Remove binding for exception e.  It's unused.

Revision 2397 - (view) (download) (as text) - [select for diffs]
Modified Mon Nov 18 23:17:41 2002 UTC (9 years, 2 months ago) by jeremy
File length: 17439 byte(s)
Diff to previous 2256
Merge ZODB 3.1 changes to the trunk.
XXX Not sure if berkeley still works.

Revision 2256 - (view) (download) (as text) - [select for diffs]
Modified Sun Sep 29 03:24:17 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 17175 byte(s)
Diff to previous 2247
Use short_repr() instead of repr() a few more places.

Revision 2247 - (view) (download) (as text) - [select for diffs]
Modified Fri Sep 27 21:57:46 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 17151 byte(s)
Diff to previous 2231
In wait(), when there's no asyncore main loop, we called
asyncore.poll() with a timeout of 10 seconds.  Change this to a
variable timeout starting at 1 msec and doubling until 1 second.

While debugging Win2k crashes in the check4ExtStorageThread test from
ZODB/tests/MTStorage.py, Tim noticed that there were frequent 10
second gaps in the log file where *nothing* happens.  These were caused
by the following scenario.

Suppose a ZEO client process has two threads using the same connection
to the ZEO server, and there's no asyncore loop active.  T1 makes a
synchronous call, and enters the wait() function.  Then T2 makes
another synchronous call, and enters the wait() function.  At this
point, both are blocked in the select() call in asyncore.poll(), with
a timeout of 10 seconds (in the old version).  Now the replies for
both calls arrive.  Say T1 wakes up.  The handle_read() method in
smac.py calls self.recv(8096), so it gets both replies in its buffer,
decodes both, and calls self.message_input() for both, which sticks
both replies in the self.replies dict.  Now T1 finds its response, its
wait() call returns with it.  But T2 is still stuck in
asyncore.poll(): its select() call never woke up, and has to "sit out"
the whole timeout of 10 seconds.  (Good thing I added timeouts to
everything!  Or perhaps not, since it masked the problem.)

One other condition must be satisfied before this becomes a disaster:
T2 must have started a transaction, and all other threads must be
waiting to start another transaction.  This is what I saw in the log.
(Hmm, maybe a message should be logged when a thread is waiting to
start a transaction this way.)

In a real Zope application, this won't happen, because there's a
centralized asyncore loop in a separate thread (probably the client's
main thread) and the various threads would be waiting on the condition
variable; whenever a reply is inserted in the replies dict, all
threads are notified.  But in the test suite there's no asyncore loop,
and I don't feel like adding one.  So the exponential backoff seems
the easiest "solution".

Revision 2231 - (view) (download) (as text) - [select for diffs]
Modified Wed Sep 25 22:28:10 2002 UTC (9 years, 4 months ago) by jeremy
File length: 16552 byte(s)
Diff to previous 2230
Fix error handling logic for pickling errors.

If an exception occurs while decoding a message, there is really
nothing the server can do to recover.  If the message was a
synchronous call, the client will wait for ever for the reply.  The
server can't send the reply, because it couldn't unpickle the message
id.  Instead of trying to recover, just let the exception propogate up
to asyncore where the connection will be closed.

As a result, eliminate DecodingError and special case in
handle_error() that handled flags == None.

Revision 2230 - (view) (download) (as text) - [select for diffs]
Modified Wed Sep 25 22:12:08 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 16758 byte(s)
Diff to previous 2226
send_reply(): catch errors in encode() and send a ZRPCError exception
instead.

return_error(): be more careful calling repr() on err_value.

Revision 2226 - (view) (download) (as text) - [select for diffs]
Modified Tue Sep 24 12:48:01 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 16363 byte(s)
Diff to previous 2224
Fix the control flow in pending().  Thanks to Ury Marshak!!!

Rather than blaming window for reporting success as an error, the
else clause on the second try block should be an except clause.

Revision 2224 - (view) (download) (as text) - [select for diffs]
Modified Mon Sep 23 20:20:07 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 16478 byte(s)
Diff to previous 2219
Various repairs and nits:

- Change pending() to use select.select() instead of select.poll(), so
  it'll work on Windows.

- Clarify comment to say that only Exceptions are propagated.

- Change some private variables to public (everything else is public).

- Remove XXX comment about logging at INFO level (we already do that
  now :-).

Revision 2219 - (view) (download) (as text) - [select for diffs]
Modified Fri Sep 20 17:37:34 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 16734 byte(s)
Diff to previous 2212
I set out making wait=1 work for fallback connections, i.e. the
ClientStorage constructor called with both wait=1 and
read_only_fallback=1 should return, indicating its readiness, when a
read-only connection was made.  This is done by calling
connect(sync=1).  Previously this waited for the ConnectThread to
finish, but that thread doesn't finish until it's made a read-write
connection, so a different mechanism is needed.

I ended up doing a major overhaul of the interfaces between
ClientStorage, ConnectionManager, ConnectThread/ConnectWrapper, and
even ManagedConnection.  Changes:

ClientStorage.py:

  ClientStorage:

  - testConnection() now returns just the preferred flag; stubs are
    cheap and I like to have the notifyConnected() signature be the
    same for clients and servers.

  - notifyConnected() now takes a connection (to match the signature
    of this method in StorageServer), and creates a new stub.  It also
    takes care of the reconnect business if the client was already
    connected, rather than the ClientManager.  It stores the
    connection as self._connection so it can close the previous one.
    This is also reset by notifyDisconnected().

zrpc/client.py:

  ConnectionManager:

  - Changed self.thread_lock into a condition variable.  It now also
    protects self.connection.  The condition is notified when
    self.connection is set to a non-None value in connect_done();
    connect(sync=1) waits for it.  The self.connected variable is no
    more; we test "self.connection is not None" instead.

  - Tried to made close() reentrant.  (There's a trick: you can't set
    self.connection to None, conn.close() ends up calling close_conn()
    which does this.)

  - Renamed notify_closed() to close_conn(), for symmetry with the
    StorageServer API.

  - Added an is_connected() method so ConnectThread.try_connect()
    doesn't have to dig inside the manager's guts to find out if the
    manager is connected (important for the disposition of fallback
    wrappers).

  ConnectThread and ConnectWrapper:

  - Follow above changes in the ClientStorage and ConnectionManager
    APIs: don't close the manager's connection when reconnecting, but
    leave that up to notifyConnected(); ConnectWrapper no longer
    manages the stub.

  - ConnectWrapper sets self.sock to None once it's created a
    ManagedConnection -- from there on the connection is is charge of
    closing the socket.

zrpc/connection.py:

  ManagedServerConnection:

  - Changed the order in which close() calls things; super_close()
    should be last.

  ManagedConnection:

  - Ditto, and call the manager's close_conn() instead of
    notify_closed().

tests/testZEO.py:

  - In checkReconnectSwitch(), we can now open the client storage with
    wait=1 and read_only_fallback=1.

Revision 2212 - (view) (download) (as text) - [select for diffs]
Modified Thu Sep 19 03:51:23 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 16737 byte(s)
Diff to previous 2211
The mystery of the Win98 hangs in the checkReconnectSwitch() test
until I added an is_connected() test to testConnection() is solved.

After the ConnectThread has switched the client to the new, read-write
connection, it closes the read-only connection(s) that it was saving
up in case there was no read-write connection.  But closing a
ManagedConnection calls notify_closed() on the manager, which
disconnected the manager and the client from its brand new read-write
connection.  The mistake here is that this should only be done when
closing the manager's current connection!

The fix was to add an argument to notify_closed() that passes the
connection object being closed; notify_closed() returns without doing
a thing when that is not the current connection.

I presume this didn't happen on Linux because there the sockets
happened to connect in a different order, and there was no read-only
connection to close yet (just a socket trying to connect).

I'm taking out the previous "fix" to ClientStorage, because that only
masked the problem in this relatively simple test case.  The problem
could still occur when both a read-only and a read-write server are up
initially, and the read-only server connects first; once the
read-write server connects, the read-write connection is installed,
and then the saved read-only connection is closed which would again
mistakenly disconnect the read-write connection.

Another (related) fix is not to call self.mgr.notify_closed() but to
call self.mgr.connection.close() when reconnecting.  (Hmm, I wonder if
it would make more sense to have an explicit reconnect callback to the
manager and the client?  Later.)

Revision 2211 - (view) (download) (as text) - [select for diffs]
Modified Thu Sep 19 03:25:59 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 16733 byte(s)
Diff to previous 2206
Define __str__ as an alias for __repr__.  Otherwise __str__ will get
the socket's __str__ due to a __getattr__ method in asyncore's
dispatcher base class that everybody hates but nobody dares take away.

Revision 2206 - (view) (download) (as text) - [select for diffs]
Modified Tue Sep 17 21:17:55 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 16669 byte(s)
Diff to previous 2205
Remove the code from call() (and wait()) that serialized outgoing
calls.  If multiple threads sharing a ZEO connection want to make
overlapping calls, they can do that now.  This is mostly useful when
one thread is waiting for a long-running pack() or undo*() call -- the
other thread can now proceed.

Jeremy & I did a review of the StorageServer code and found no place
where overlapping incoming calls from the same connection could do any
harm -- given that the only places where incoming calls can be handled
are those places where the server makes a callback to the client.

Revision 2205 - (view) (download) (as text) - [select for diffs]
Modified Tue Sep 17 21:07:00 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 17152 byte(s)
Diff to previous 2193
Remove redundant class ServerConnection.

Cleanup comments for Managed*Connection.

Whitespace normalization.

Revision 2193 - (view) (download) (as text) - [select for diffs]
Modified Tue Sep 17 16:33:33 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 17473 byte(s)
Diff to previous 2189
When a call in the server raises an exception that is passed back to
the client, don't log it at the ERROR level.  If it really was a
disaster, the client should log it.  But if the client was expecting
the exception, the esrver shouldn't get all upset about it.  Change
this to the INFO level.  (When it *is* considered an error by the
client, it's useful to be able to see the server-side traceback in the
log.)

Revision 2189 - (view) (download) (as text) - [select for diffs]
Modified Tue Sep 17 15:11:36 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 17474 byte(s)
Diff to previous 2182
Remove unused argument in poll().  Fix comment in pending().

Revision 2182 - (view) (download) (as text) - [select for diffs]
Modified Tue Sep 17 03:15:26 2002 UTC (9 years, 4 months ago) by jeremy
File length: 17494 byte(s)
Diff to previous 2180
Move "send msg" and "recv msg" log calls to debug level.

Revision 2180 - (view) (download) (as text) - [select for diffs]
Modified Mon Sep 16 22:06:41 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 17466 byte(s)
Diff to previous 2175
This checkin contains changes (by me) that will allow multiple
parallel outstanding calls.  However it also contains code (by Jeremy,
with one notifyAll() call added by me) that enforces the old rule of a
single outstanding call.  This is hopefully unnecessessary, but we
haven't reviewed the server side yet to make sure that that's really
the case (the server was until now getting serialized calls per
connection).

Revision 2175 - (view) (download) (as text) - [select for diffs]
Modified Mon Sep 16 02:42:43 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 16794 byte(s)
Diff to previous 2165
Remove two unused __super_<method> definitions.

Revision 2165 - (view) (download) (as text) - [select for diffs]
Modified Fri Sep 13 20:55:22 2002 UTC (9 years, 4 months ago) by gvanrossum
File length: 16936 byte(s)
Diff to previous 2153
Subtle wording changes to the call and return log messages.

Revision 2153 - (view) (download) (as text) - [select for diffs]
Modified Thu Sep 12 21:18:19 2002 UTC (9 years, 4 months ago) by jeremy
File length: 16927 byte(s)
Diff to previous 2141
Major refactoring of the rpc locking mechanisms.

Add a send_call() method that computes a new msgid and hands the
message off to the smac layer.  Uses __msgid_lock()

call() still uses __call_lock, but callAsync() does not.  callAsync()
does not use any lock beyond what send_call() does.

Revision 2141 - (view) (download) (as text) - [select for diffs]
Modified Wed Sep 11 21:28:39 2002 UTC (9 years, 5 months ago) by jeremy
File length: 16852 byte(s)
Diff to previous 2140
Raise DisconnectedError consistently.

Revision 2140 - (view) (download) (as text) - [select for diffs]
Modified Wed Sep 11 21:27:02 2002 UTC (9 years, 5 months ago) by jeremy
File length: 16932 byte(s)
Diff to previous 2138
Oops.  The type test is necessary.  issubclass() can raise a TypeError.

Revision 2138 - (view) (download) (as text) - [select for diffs]
Modified Wed Sep 11 21:21:24 2002 UTC (9 years, 5 months ago) by jeremy
File length: 16881 byte(s)
Diff to previous 2128
Extend Delay objects with an error() method that send an exception to
the client.

Also, simplify the test for exceptions received by the client.  If the
class is a subclass of Exception, there's no need to ask if the
instance is of type ClassType.

Revision 2128 - (view) (download) (as text) - [select for diffs]
Modified Tue Sep 10 22:08:44 2002 UTC (9 years, 5 months ago) by gvanrossum
File length: 16528 byte(s)
Diff to previous 2109
There's no need for notify_closed() to take a 'conn' argument.

Revision 2109 - (view) (download) (as text) - [select for diffs]
Modified Sun Sep 8 00:16:38 2002 UTC (9 years, 5 months ago) by jeremy
File length: 16532 byte(s)
Diff to previous 2106
Add pending() method to Connection.

Revision 2106 - (view) (download) (as text) - [select for diffs]
Modified Sat Sep 7 23:45:09 2002 UTC (9 years, 5 months ago) by jeremy
File length: 15355 byte(s)
Diff to previous 2092
Rename _do_async_loop() and _do_async_poll() to wait() and poll().
Repair comments in _call() about how wait() handles reply lock.

Revision 2092 - (view) (download) (as text) - [select for diffs]
Modified Thu Sep 5 19:28:47 2002 UTC (9 years, 5 months ago) by jeremy
File length: 15698 byte(s)
Diff to previous 2080
Move smac from ZEO to ZEO.zrpc.

Revision 2080 - (view) (download) (as text) - [select for diffs]
Modified Fri Aug 30 21:42:30 2002 UTC (9 years, 5 months ago) by gvanrossum
File length: 15717 byte(s)
Diff to previous 2071
Whitespace normalization.

Revision 2071 - (view) (download) (as text) - [select for diffs]
Modified Thu Aug 29 21:59:19 2002 UTC (9 years, 5 months ago) by gvanrossum
File length: 15723 byte(s)
Diff to previous 2070
It still bugged me that the manager method called by the connection
when the connection is closed is called 'close()' when it doesn't
close the manager, but tells the manager that one particular
connection is closed.  Rename it to 'close_conn()'.

Revision 2070 - (view) (download) (as text) - [select for diffs]
Modified Thu Aug 29 21:35:41 2002 UTC (9 years, 5 months ago) by jeremy
File length: 15718 byte(s)
Diff to previous 2035
Call notifyDisconnected() on the object handled by a Connection.

Revision 2035 - (view) (download) (as text) - [select for diffs]
Modified Fri Aug 23 19:32:37 2002 UTC (9 years, 5 months ago) by jeremy
File length: 15675 byte(s)
Diff to previous 2002
Expand some comments and docstrings.

Revision 2002 - (view) (download) (as text) - [select for diffs]
Modified Mon Aug 12 20:32:27 2002 UTC (9 years, 6 months ago) by jeremy
File length: 14299 byte(s)
Diff to previous 1995
Clear up comment inside _do_async_loop() and assert that lock is not held.

Revision 1995 - (view) (download) (as text) - [select for diffs]
Modified Fri Aug 9 20:35:36 2002 UTC (9 years, 6 months ago) by jeremy
File length: 14325 byte(s)
Diff to previous 1994
Import select to make previous checkin work.

Revision 1994 - (view) (download) (as text) - [select for diffs]
Modified Fri Aug 9 20:32:49 2002 UTC (9 years, 6 months ago) by jeremy
File length: 14311 byte(s)
Diff to previous 1989
Add a close() method to the ZEOStorage that closes connection to client.

XXX If select() raises an exception inside asyncore, close the connection.

Revision 1989 - (view) (download) (as text) - [select for diffs]
Modified Tue Aug 6 23:10:31 2002 UTC (9 years, 6 months ago) by jeremy
File length: 14097 byte(s)
Diff to previous 1969
Add MTDelay() that blocks reply() on an event until send_reply() is ready.

Add a poll call in send_reply() so that synchronous calls made when
there is no other traffic don't cause long delays.  (This probably
only occurs during the pack tests.)

Revision 1969 - (view) (download) (as text) - [select for diffs]
Modified Thu Aug 1 18:46:50 2002 UTC (9 years, 6 months ago) by jeremy
File length: 13775 byte(s)
Diff to previous 1966
Make doubly sure that SystemExit isn't caught be generic error handling.

Revision 1966 - (view) (download) (as text) - [select for diffs]
Modified Fri Jul 26 20:54:47 2002 UTC (9 years, 6 months ago) by jeremy
File length: 13601 byte(s)
Diff to previous 1950
Use short_repr() for log at BLATHER level for method invocation.

I think this is the log call that has been killing backends by sending
very large strings.

Revision 1950 - (view) (download) (as text) - [select for diffs]
Modified Thu Jun 27 15:06:55 2002 UTC (9 years, 7 months ago) by htrd
File length: 13571 byte(s)
Diff to previous 1880
merge change from ZEO2-branch; fix bug that caused exceptions log entries to be mangled

Revision 1880 - (view) (download) (as text) - [select for diffs]
Added Tue Jun 11 19:22:26 2002 UTC (9 years, 8 months ago) by jeremy
File length: 13556 byte(s)
Merge ZEO2-branch to trunk.  (Files added on branch.)

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

  Diffs between and
  Type of Diff should be a

Sort log by:

webmaster@zope.org

Powered by ViewCVS 1.0-dev
(Powered by Apache)

ViewCVS and CVS Help