1. 15 Apr, 2002 3 commits
    • Jeremy Hylton's avatar
      Add a bunch more tests of the LRU cache mechanism and of DB methods. · 43fa28e3
      Jeremy Hylton authored
      Also, reformat a test in testTransaction.
      43fa28e3
    • Jeremy Hylton's avatar
      Remove the cache_deactivate_after argument from the cPickleCache · 8007802d
      Jeremy Hylton authored
      constructor, since it is ignored and there is no current plan to
      support two caches with almost-but-not-quite-the-same arguments.
      
      This change has effects in many files.  The Connection and DB don't
      pass this argument and don't bother setting it explicitly when it is
      reset via DB APIs like setCacheDeactivateAfter().  XXX These APIs
      remain, since existing code may depend on them, but they have no
      effect.
      
      New policy in cPersistence.c: A Persistent object can't have its
      _p_jar set or deleted once it is in a cache.  Persistent already
      implemented this policy for _p_oid; it seems safer to do the same for
      the jar.
      
      Add ringlen() method to cache objects (implemented as cc_ringlen).
      This returns the length of the doubly linked list of non-ghost
      objects.  Same as len(cache.lru_items()), but more efficient.  Only
      used for testing at the moment.
      
      In ring_corrupt(), don't raise a new exception if one has already been
      set.  The old behavior masked useful information about the original
      error / traceback.
      8007802d
    • Chris Withers's avatar
      Change void* to char* to make VC++ happy. · bc0d92c9
      Chris Withers authored
      bc0d92c9
  2. 13 Apr, 2002 1 commit
  3. 12 Apr, 2002 4 commits
    • Jeremy Hylton's avatar
      Sundry changes. · 046da4a8
      Jeremy Hylton authored
      Implement behavior for minimize() and full_sweep() as discussed on
      zodb-dev.  minimize() ghostifies all unmodified objects.  full_sweep()
      with age==0 is the same as minimize(), otherwise it's the same as
      incrgc().
      
      Reformat and/or reindent lots of code.
      
      Use PyObject_Compare() instead of PyObject_Cmp() because it has a
      simpler return value.
      
      Fix a few more PyDict_SetItem() and PyDict_DelItem() calls to make
      correct check for error return.
      046da4a8
    • Jeremy Hylton's avatar
      Refactor the commit() method. · 56ab4405
      Jeremy Hylton authored
      Break up the logic into a bunch of helper methods:
       _commit_objects()
       _commit_subtrans()
       _finish_one()
       _finish_rest()
      and possibly
       _commit_error()
      
      As a result of the changes, the high-level logic of a commit fits into
      28 lines inside a try/finally.  There are lots of details hidden in
      the methods, but the names capture the high-level behavior of the
      helpers.
      56ab4405
    • Jeremy Hylton's avatar
      Wrap abort_sub() call in try/except that logs exception and continues. · 722fc658
      Jeremy Hylton authored
      This fixes the transient failure in testExceptionInSubAbortSub() and
      is presumed to be correct, too.  The old code had the comment:
          # This should never fail
      but did not to guarantee that it never failed.  I'm assuming that the
      write fix is to log the error and ignore it, because that's what the
      call to tpc_abort() immediately above does.
      
      XXX commit() is a really long method.  It would be nice to break it up
      into easier-to-understand chunks.
      722fc658
    • Jeremy Hylton's avatar
      Cosmetic changes to ExceptionInSubAbortSub, · f7739565
      Jeremy Hylton authored
      including some use of assert/fail methods instead of assert stmt.
      f7739565
  4. 05 Apr, 2002 1 commit
    • Jeremy Hylton's avatar
      Move cc_oid_unreferenced() into the C API and out of Python. · 75ee5c7a
      Jeremy Hylton authored
          The rationale is that this is an internal detail of the cache
          implementation called by Per_dealloc().  It's nice to make it
          fast, and it's good to prevent it from being called with anything
          other than an about-to-be-freed object.
      
          As a result of it being in the C API, omit tests of refcounts.  We
          would have been in Per_dealloc() otherwise.
      
          Initialize the percachdel slot of cPersistenceAPIstruct to NULL in
          cPersistence.  In cPickleCache, import the CObject and fill in the
          struct.
      
      Also, reformat many of the comments so that all the text starts to the
      right of the /*.
      
      Fiddle the text of the placeholder comment.  I think I understand it
      now :-).
      
      Add an XXX comment about the "old" cache API e.g. fullsweep and
      reallyfullsweep.
      
      Fix cc_get().  object_from_oid() doesn't ever set an exception.
      
      Remove a Py_FatalError() check from the end of a module init
      function.  We don't do that anymore.
      75ee5c7a
  5. 04 Apr, 2002 3 commits
  6. 03 Apr, 2002 5 commits
  7. 02 Apr, 2002 10 commits
  8. 01 Apr, 2002 2 commits
    • Jeremy Hylton's avatar
      Cache cleanups. · 5cd55aa4
      Jeremy Hylton authored
      Remove use of staticforward.
      
      Avoid forward reference to Cctype by defining newccobject after type
      struct.
      5cd55aa4
    • Jeremy Hylton's avatar
      Some first cosmetic changes to the new cache implementation. · 09125899
      Jeremy Hylton authored
      Define the contents of ccobject_head_struct via CACHE_HEAD macro.
      Don't rely on two different files to define a struct with the same
      layout by convention.
      
      Remove many levels of parentheses from the HOME and NON_GHOST_COUNT
      macros.
      
      Replace KEEP_THIS_ONE_AROUND_FOR_A_WHILE() macro with a call to the
      accessed() function.  (Who comes up with these names :-).
      
      Remove include of string.h in cPersistence.c.
      
      Expand cPersistent_HEAD macro so that it has one line for each
      attribute!
      
      Use typedef to define PerCache as "struct ccobject_head_struct" and
      use this for the entry cache slot in cPersistent_HEAD instead of
      PyObject *.
      
      In cPickleCache.c, reflow a bunch of long lines, add some whitespace,
      and an XXX comment explaining that I don't understand a different
      comment.
      09125899
  9. 30 Mar, 2002 2 commits
    • Jeremy Hylton's avatar
      Two new tests. · 86cc6f96
      Jeremy Hylton authored
      These tests verify that transactional undo works with abortVersion and
      commitVersion, even in the face of a pack that invalidates the file
      position contained in the transaction record.
      86cc6f96
    • Jeremy Hylton's avatar
      Simplify transactional undo implementation. · 6b003959
      Jeremy Hylton authored
      Use the file position stored in the transaction_id whenever possible.
      It is possible when _check_txn_pos() returns true; i.e. when the file
      position does point to the transaction record header.
      
      Remove ostloc and here arguments to _txn_undo_write(), as they can be
      computed after the call.
      
      Omit redundant tests in _txn_undo_write().  All the paths that lead
      here verify that the file position is valid.
      
      Remove some attribute lookup optimizations.
      6b003959
  10. 29 Mar, 2002 9 commits
    • Jeremy Hylton's avatar
      Break up transactionalUndo() into possibly understandable chunks. · 0e8427c9
      Jeremy Hylton authored
      transactionalUndo() does argument checking and locking.  It calls
      _transactional_undo(), which finds the right transaction record.  It calls
      _txn_undo_write(), which writes the data records.
      
      Add a summary comment above undoLog() that explains how the
      transaction_id is created and used.
      0e8427c9
    • Jeremy Hylton's avatar
      Move undoLog() before transactionalUndo(). · 8f9d1fc4
      Jeremy Hylton authored
      It makes more sense in this order, because the comments in undoLog()
      help to explain what transactionalUndo() is doing.
      8f9d1fc4
    • Jeremy Hylton's avatar
      663174eb
    • Jeremy Hylton's avatar
      Simplify implementation of undoLog() and add comment about how it · 7b1532bf
      Jeremy Hylton authored
      appears to be broken.
      7b1532bf
    • Shane Hathaway's avatar
      The file position has to be encoded in the transaction ID for non-transactional · 065bfea5
      Shane Hathaway authored
      undo to continue to work, and the IDs have to be base64 encoded to work on
      HTML forms.  In future, non-transactional undo may be removed and the HTML
      forms might be updated to perform the encoding of transaction IDs.
      065bfea5
    • Barry Warsaw's avatar
      Here is a fix for a problem reported against the standby replicas. In · 606639c4
      Barry Warsaw authored
      that environment, it is possible that all the data in the replicas
      recoverable through the public api are identical, while the actual
      on-disc representation differs.  This bug can be boiled down to doing
      the following in "standard" ZODB:
      
          1. undoLog()
          2. pack()
          3. transactionalUndo()
      
      Previously, undoLog() encoded the file position in the 'id' key of the
      undo record, but of course the pack() breaks that file position.  We
      fix this by encoding the oid of an object touched in the transaction
      instead.  That way, transactionalUndo() can start at the current
      revision of the object, and scan back until it can find a transaction
      with a matching id to the one we're undoing.
      
      This approach breaks when the transaction we're undoing doesn't touch
      any objects, e.g. is an abortVersion() or commitVersion().  By edict,
      that's a non-requirement for now.  We could fix that by doing a more
      expensive binary search for the matching transaction.
      
      WIBNI we had an index from tids to file positions? :)
      606639c4
    • Barry Warsaw's avatar
      checkTransactionalUndoAfterPack(): Removed two tests that weren't · d9c08573
      Barry Warsaw authored
      really testing what we're interested in (they were testing the
      equality of the exact layout of the undoInfo() -- not interesting).
      d9c08573
    • Barry Warsaw's avatar
      checkTransactionalUndoAfterPack(): A better test which confirms the · 84a87a68
      Barry Warsaw authored
      suspicion that FileStorage (and an FS-backed ZEO) fails a
      transactional undo after a pack, but Berkeley storage passes.
      84a87a68
    • Jeremy Hylton's avatar
      Don't pass a revid to pack(). Pass the current time. · 6410bd0f
      Jeremy Hylton authored
      Two problems: A revid doesn't have the right type.  But even if we
      decoded the revid using TimeStamp(revid).timeTime(), it would be the
      wrong time.  We want to pack to the current time to delete older
      revisions.
      
      I believe the test case tried to keep one revision available so that
      it could be packed.  The new test doesn't do that, so it will fail
      even after we fix FileStorage.  I think the right answer is to call
      time.time() after the second commit *and* make sure that there is at
      least a one second delay between the two stores.
      6410bd0f