Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes feed has negative pending value #513

Closed
robsonvn opened this issue May 10, 2017 · 3 comments
Closed

changes feed has negative pending value #513

robsonvn opened this issue May 10, 2017 · 3 comments

Comments

@robsonvn
Copy link

robsonvn commented May 10, 2017

Hi folks,

I'm running a test in which two entries are updated in the following order: test1, test2.

when I query http://127.0.0.1:5984/doctrine_test_database/_changes

Sometimes I get this order:

{
  "results": [
    {
      "seq": "1-g1AAAAF1eJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rgzmRMRcowG5pbmloYWKKTQMeY5IUgGSSPcikRAZ86hxA6uIJq0sAqasnqC6PBUgyNAApoNL5xKhdAFG7nxi1ByBq7xOj9gFELci9WQBea3jf",
      "id": "test2",
      "changes": [
        {
          "rev": "1-c86e975fffb4a635eed6d1dfc92afded"
        }
      ]
    },
    {
      "seq": "2-g1AAAAHleJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rgzmRMRcowG5pbmloYWKKTQMeY5IUgGSSPdQkBrBJaQYWJkmWFikMnKV5KalpmXmpKfhMcACZEI9igqmxcYqhiRGxJiSATKhHMcHEIC0x2TyNSBPyWIAkQwOQAhoyHxEmpskmFimmliSGCcS0BRDT9mclMhBUewCi9j4xah9A1P4Hqs0CAIaTl3s",
      "id": "test1",
      "changes": [
        {
          "rev": "1-4c6114c65e295552ab1019e2b046b10e"
        }
      ]
    }
  ],
  "last_seq": "2-g1AAAAIzeJyV0EEOgjAQBdAqJurSE-gRCrTSruQmSjttKqmwUNZ6E72J3kRvgkVMgMQQ2cwkM5mXybcIoZnxAC1kXkgDIra5TKzJjyfrVuMEiWVZlqnxktHBDaY84j4j9NdBDyNWrorNV0IfSWNGBGeA5kUGSu8zBX1CXAnbjkDDEHwS_CvsKuHcEQjWiYz0n0I2cRVdXHPItcmESsKA8oGZ1Nqt1u7NT1j5igp_0E-PWnk2SkgjoGyY8qqVVj7rKMCKkbaSvgGlZaup",
  "pending": 0
}

sometimes this:

{
  "results": [
    {
      "seq": "1-g1AAAAHDeJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rkQGPoiQFIJlkD1KXwZzIkAvksacZWJgkWVqkMHCW5qWkpmXmpabgM8EBZEI8igmmxsYphiZGxJqQADKhHsUEE4O0xGTzNCJNyGMBkgwNQApoyHyQKYwQdySbWKSYWmLTR9C0BRDT9uMPP4jaAxC194lR-wCiFhQvWQC-343K",
      "id": "test1",
      "changes": [
        {
          "rev": "1-4c6114c65e295552ab1019e2b046b10e"
        }
      ]
    },
    {
      "seq": "2-g1AAAAHleJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rgzmRMRcowG5pbmloYWKKTQMeY5IUgGSSPdQkBrBJaQYWJkmWFikMnKV5KalpmXmpKfhMcACZEI9igqmxcYqhiRGxJiSATKhHMcHEIC0x2TyNSBPyWIAkQwOQAhoyHxEmpskmFimmliSGCcS0BRDT9mclMhBUewCi9j4xah9A1P4Hqs0CAIaTl3s",
      "id": "test2",
      "changes": [
        {
          "rev": "1-c86e975fffb4a635eed6d1dfc92afded"
        }
      ]
    }
  ],
  "last_seq": "2-g1AAAAIzeJyV0EEOgjAQBdAqJurSE-gRCrTSruQmSjttKqmwUNZ6E72J3kRvgkVMgMQQ2cwkM5mXybcIoZnxAC1kXkgDIra5TKzJjyfrVuMEiWVZlqnxktHBDaY84j4j9NdBDyNWrorNV0IfSWNGBGeA5kUGSu8zBX1CXAnbjkDDEHwS_CvsKuHcEQjWiYz0n0I2cRVdXHPItcmESsKA8oGZ1Nqt1u7NT1j5igp_0E-PWnk2SkgjoGyY8qqVVj7rKMCKkbaSvgGlZaup",
  "pending": 0
}

Assuming that the documentation says that I must use descending=true to sort by the most recent change, and there's no ascending parameter, so it should be always sorted in ascending way.

The descending parameter is not working properly as well

{
  "results": [
    {
      "seq": "2-g1AAAAGpeJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rkRGPoiQFIJlkD1KXwZzIkAvksacZWJgkWVqkMHCW5qWkpmXmpabgM8EBZEI82CYGfOoSQOrqUWwyMUhLTDZPI9KmPBYgydAApICGzAeZwgg2xTTZxCLF1BKbPoKmLYCYth-_2yFqD0DU3idG7QOIWlCYZAEAn36HNw",
      "id": "test1",
      "changes": [
        {
          "rev": "1-4c6114c65e295552ab1019e2b046b10e"
        }
      ]
    },
    {
      "seq": "2-g1AAAAHleJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rgzmRMRcowG5pbmloYWKKTQMeY5IUgGSSPdQkBrBJaQYWJkmWFikMnKV5KalpmXmpKfhMcACZEA8yIZEBn7oEkLp6FJtMDNISk83TiLQpjwVIMjQAKaAh8xE-N002sUgxtSTR5xDTFkBM24_f7RC1ByBq7yPcb2xqnmJqYUiS-x9ATAGFVhYACduXhg",
      "id": "test2",
      "changes": [
        {
          "rev": "1-c86e975fffb4a635eed6d1dfc92afded"
        }
      ]
    }
  ],
  "last_seq": "2-g1AAAAIzeJyV0EEOgjAQBdAqJurSE-gRCrTSruQmSjttKqmwUNZ6E72J3kRvgkVMgMQQ2cwkM5mXybcIoZnxAC1kXkgDIra5TKzJjyfrVuMEiWVZlqnxktHBDaY84j4j9NdBDyNWrorNV0IfSWNGBGeA5kUGSu8zBX1CXAnbjkDDEHwS_CvsKuHcEQjWiYz0n0I2cRVdXHPItcmESsKA8oGZ1Nqt1u7NT1j5igp_0E-PWnk2SkgjoGyY8qqVVj7rKMCKkbaSvgGlZaup",
  "pending": -2
}

Besides the order is wrong (should be test2,test1) the pending value is -2 but there are only two changes.

@dmunch
Copy link
Contributor

dmunch commented May 16, 2017

I'm not entirely sure about pending, but I think it's important to understand the concept of _changes ordering - in CouchDB 2.0 the _changes feed is only partially ordered. You can find more information on this discussion.

@wohali wohali changed the title db/_changes result order is being random and descending=true is not working changes feed has negative pending value May 16, 2017
@wohali
Copy link
Member

wohali commented May 16, 2017

What @dmunch says is correct - we do not guarantee strict ordering, but we do guarantee that for any specific given document, you will get a consistent order from us such that the changes can be replayed in an idempotent fashion.

However, the negative pending value is unexplained, and I'm changing the bug report title to reflect that as the ongoing concern in this issue.

@wohali
Copy link
Member

wohali commented May 16, 2017

Per IRC chat with @davisp:

shard combinations can cause that. because we're not sending an update_seq with the pending changes request, so if it gets a different set of shards it can go wonky like that.

In other words, both behaviours are expected with CouchDB 2.0.

@wohali wohali closed this as completed May 16, 2017
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

No branches or pull requests

3 participants