nickva commented on code in PR #5611: URL: https://github.com/apache/couchdb/pull/5611#discussion_r2248744813
########## src/couch/src/couch_bt_engine_header.erl: ########## @@ -204,17 +204,16 @@ upgrade_tuple(Old) when is_record(Old, db_header) -> Old; upgrade_tuple(Old) when is_tuple(Old) -> NewSize = record_info(size, db_header), - if - tuple_size(Old) < NewSize -> ok; - true -> erlang:error({invalid_header_size, Old}) - end, - {_, New} = lists:foldl( - fun(Val, {Idx, Hdr}) -> - {Idx + 1, setelement(Idx, Hdr, Val)} + Upgrade = tuple_size(Old) < NewSize, + ProhibitDowngrade = config:get_boolean("couchdb", "prohibit_downgrade", true), + OldKVs = + case {Upgrade, ProhibitDowngrade} of + {true, AnyBool} when is_boolean(AnyBool) -> tuple_to_list(Old); + {false, true} -> error({invalid_header_size, Old}); + {false, false} -> lists:sublist(tuple_to_list(Old), NewSize) Review Comment: I'll update the commit comment, as it was missing the part that is only meant for cases when the disk version hasn't changed and is meant to work along with the feature were we allowed "easy" upgrades by just appending fields to the header -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@couchdb.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org