Skip to content

Conversation

@nickva
Copy link
Contributor

@nickva nickva commented Jul 30, 2025

Currently, CouchDB on-disk header record allows appending new fields to it in such a way that newer versions can upgrade themselves from the old versions easily if the ?LATEST_DISK_VERSION stays the same. However, it was not possible to perform a downgrade back to an old version in case something went wrong.

While in general it may not be safe to downgrade in such cases, it may be possible for some features, so allow for such an option and make it configurable.

This is essentially a counterpart to this feature:

% As long the changes are limited to new header fields (with inline
% defaults) added to the end of the record, then there is no need to increment
% the disk revision number.

The release notes of future releases may indicate which version are downgrade safe. Then, to perform a downgrade users would enable the downgrade flag, downgrade, and then reset it back to default (prohibit = true).

Implementation-wise, it's pretty basic, if the size of the new tuple is larger than the old one, it's a downgrade. Then, only use as many tuple fields as current (aka the "old" version) knows about, everything else is discarded.

@nickva nickva force-pushed the allow-downgrades-option branch 2 times, most recently from b44806c to fda4dfb Compare July 30, 2025 21:42
@nickva nickva changed the title Implement the ability to downgrade CouchDB versions Implement the ability to downgrade CouchDB versions even on header field changes Jul 30, 2025
@nickva nickva force-pushed the allow-downgrades-option branch 3 times, most recently from 7a4cb78 to dde32ff Compare August 3, 2025 17:06
; Note that some future versions of CouchDB might not support downgrade at all,
; whatever value this is set to. In those cases CouchDB will refuse to
; downgrade or even open the databases in question.
;prohibit_downgrade = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you consider using positive logic?

; allow_downgrade = false

I don't mind either way.

Copy link
Contributor Author

@nickva nickva Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did start that way actually, the pr branch is even named allow-downgrades-option, but there was a discussion in dev to improve wording and naming and I think we settled on having something that expresses the default as a true value. I am ok either way as well, but prohibit does sound a bit stronger and more worrisome which is a good thing in this case.

Copy link
Contributor

@iilyak iilyak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Currently, CouchDB on-disk header record allows appending new fields to it in
such a way that newer versions can upgrade themselves from the old versions
easily if the ?LATEST_DISK_VERSION stays the same. However, it was not possible
to perform a downgrade back to an old version in case something went wrong.

While in general it may not be safe to downgrade in such cases, it may be
possible for some features, so allow for such an option and make it
configurable.

This is essentially a counterpart to this feature:

```
% As long the changes are limited to new header fields (with inline
% defaults) added to the end of the record, then there is no need to increment
% the disk revision number.
```

The release notes of future releases may indicate which version are downgrade
safe. Then, to perform a downgrade users would enable the downgrade flag,
downgrade, and then reset it back to default (prohibit = true).

Implementation-wise, it's pretty basic, if the size of the new tuple is larger
than the old one, it's a downgrade. Then, only use as many tuple fields as
current (aka the "old" version) knows about, everything else is discarded.
@nickva nickva force-pushed the allow-downgrades-option branch from dde32ff to ce5b584 Compare August 6, 2025 15:01
@nickva nickva merged commit de46fea into main Aug 6, 2025
23 checks passed
@nickva nickva deleted the allow-downgrades-option branch August 6, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants