Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MB-7542: Set seq_id to 1 if not set or as zero

For offline upgrade or data restore, set seq_id to 1 when it is not set
or set as zero.

Change-Id: I5ff72068dfb07026e6cc528bf467055bcfe8b00f
Reviewed-on: http://review.couchbase.org/24003
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Bin Cui <bin.cui@gmail.com>
Reviewed-on: http://review.couchbase.org/24034
  • Loading branch information...
commit afc26d0f9df2837a8e047c0340781f8a024a7721 1 parent b9ba5c1
@bcui6611 bcui6611 authored Farshid Ghods committed
Showing with 26 additions and 15 deletions.
  1. +7 −3 pump_mc.py
  2. +19 −12 pump_sfd.py
View
10 pump_mc.py
@@ -332,10 +332,14 @@ def cmd_request(self, cmd, vbucket_id, key, val, flg, exp, cas, meta, opaque):
if len(seq_no) < 8:
# The seq_no might be 32-bits from 2.0DP4, so pad with 0x00's.
seq_no = ('\x00\x00\x00\x00\x00\x00\x00\x00' + seq_no)[-8:]
- ext = (struct.pack(">II", flg, exp) + seq_no +
- struct.pack(">Q", cas))
+ check_seqno, = struct.unpack(">Q", seq_no)
+ if check_seqno:
+ ext = (struct.pack(">II", flg, exp) + seq_no +
+ struct.pack(">Q", cas))
+ else:
+ ext = struct.pack(">IIQQ", flg, exp, 1, cas)
else:
- ext = struct.pack(">IIQQ", flg, exp, 0, cas)
+ ext = struct.pack(">IIQQ", flg, exp, 1, cas)
elif (cmd == memcacheConstants.CMD_SET or
cmd == memcacheConstants.CMD_ADD):
ext = struct.pack(memcacheConstants.SET_PKT_FMT, flg, exp)
View
31 pump_sfd.py
@@ -280,7 +280,13 @@ def run(self):
d = couchstore.DocumentInfo(str(key))
d.revMeta = str(struct.pack(SFD_REV_META, cas, exp, flg))
if meta:
- d.revSequence = struct.unpack(SFD_REV_SEQ, meta)
+ if len(meta) > 8:
+ meta = meta[0:8]
+ if len(meta) < 8:
+ meta = ('\x00\x00\x00\x00\x00\x00\x00\x00' + meta)[-8:]
+ d.revSequence, = struct.unpack(SFD_REV_SEQ, meta)
+ else:
+ d.revSequence = 1
if cmd == memcacheConstants.CMD_TAP_MUTATION:
v = str(val)
@@ -404,20 +410,21 @@ def consume_design(opts, sink_spec, sink_map,
bulk_keys = []
bulk_vals = []
- for row in sd['rows']:
- logging.debug("design_doc row: " + str(row))
+ if sd:
+ for row in sd['rows']:
+ logging.debug("design_doc row: " + str(row))
- d = couchstore.DocumentInfo(str(row['id']))
- if '_rev' in row['doc']:
- d.revMeta = str(row['doc']['_rev'])
- del row['doc']['_rev']
- d.contentType = couchstore.DocumentInfo.IS_JSON
+ d = couchstore.DocumentInfo(str(row['id']))
+ if '_rev' in row['doc']:
+ d.revMeta = str(row['doc']['_rev'])
+ del row['doc']['_rev']
+ d.contentType = couchstore.DocumentInfo.IS_JSON
- bulk_keys.append(d)
- bulk_vals.append(json.dumps(row['doc']))
+ bulk_keys.append(d)
+ bulk_vals.append(json.dumps(row['doc']))
- if bulk_keys and bulk_vals:
- store.saveMultiple(bulk_keys, bulk_vals) # TODO: Compress ddocs?
+ if bulk_keys and bulk_vals:
+ store.saveMultiple(bulk_keys, bulk_vals) # TODO: Compress ddocs?
store.commit()
store.close()
Please sign in to comment.
Something went wrong with that request. Please try again.