Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-1021

Compacting a database does not preserve the purge_seq

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.0.1
    • 1.0.2, 1.1
    • Database Core
    • None
    • All platforms

    • Regular Contributors Level (Easy to Medium)

    Description

      On compacting a database the purge_seq becomes zero. As a result subsequently accessing any view will cause the view to be rebuilt from scratch. I resolved the issue for me by patching start_copy_compact, but this only works if you can guarantee there will be no purging done during compaction:

      — couchdb-1.0.1/src/couchdb/couch_db_updater.erl
      +++ couchdb-1.0.1.new/src/couchdb/couch_db_updater.erl
      @@ -857,7 +857,7 @@

      commit_data(NewDb4#db

      {update_seq=Db#db.update_seq}

      ).

      -start_copy_compact(#db

      {name=Name,filepath=Filepath}

      =Db) ->
      +start_copy_compact(#db{name=Name,filepath=Filepath,header=#db_header{purge_seq=PurgeSeq}}=Db) ->
      CompactFile = Filepath ++ ".compact",
      ?LOG_DEBUG("Compaction process spawned for db \"~s\"", [Name]),
      case couch_file:open(CompactFile) of
      @@ -869,7 +869,7 @@
      couch_task_status:add_task(<<"Database Compaction">>, Name, <<"Starting">>),

      {ok, Fd}

      = couch_file:open(CompactFile, [create]),
      Retry = false,

      I am sure that there must be a better way of doing this.....

      Attachments

        Activity

          People

            Unassigned Unassigned
            mikeldy Mike Leddy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: