Navigation Menu

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

Return detailed replication stats for running and pending jobs #2292

Merged
merged 1 commit into from Nov 6, 2019

Conversation

nickva
Copy link
Contributor

@nickva nickva commented Oct 31, 2019

Overview

Previously _scheduled/docs returned detailed replication statistics for
completed jobs only. To get the same level of details from a running or pending
jobs users had to use _active_tasks, which is not optimal and required jumping
between monitoring endpoints.

info field was originally meant to hold these statistics but they were not
implemented and it just returned null as a placeholder. With work for 3.0
finalizing, this might be a good time to add this improvement to avoid
disturbing the API afterwards.

Just updating the _scheduler/docs was not quite enough since, replications
started from the _replicate endpoint would not be visible there and users
would still have to access _active_tasks to get inspect them, so let's add
the info field to the _scheduler/jobs as well.

After this update, all states and status details from _active_tasks and
_replicator docs should be available under _scheduler/jobs and
_scheduler/docs endpoints.

Testing recommendations

  1. Run couch_replicator eunit tests

(edit: unit test added for the test below as well)
2. Create a few replications and monitor _scheduler/jobs and _scheduler/docs
3. Make those jobs pending by lowering the max_jobs to 0
4. Inspect _scheduler/jobs and docs. Stats should still be showing even when the jobs are pending.
5. Delete the max_jobs setting and wait for jobs to start running against. They should keep their stats and update them when new docs are replicated over.

Related Issues or Pull Requests

Checklist

  • Code is written and works correctly
  • Changes are covered by tests
  • A PR for documentation changes will be made after discussion

@nickva
Copy link
Contributor Author

nickva commented Oct 31, 2019

Marking it as as draft pull request in order to start the discussion on the mailing list since it involves API changes

@nickva
Copy link
Contributor Author

nickva commented Oct 31, 2019

Example of _scheduler/docs response:

{
  "total_rows": 1,
  "offset": 0,
  "docs": [
    {
      "database": "_replicator",
      "doc_id": "2e5df7bf99f1a9d06feef6301300055f",
      "id": "d99e532c1129e9cacbf7ed085deca509+continuous",
      "node": "node1@127.0.0.1",
      "source": "http://adm:*****@localhost:15984/src/",
      "target": "http://adm:*****@localhost:15984/tgt/",
      "state": "pending",
      "info": {
        "revisions_checked": 113,
        "missing_revisions_found": 113,
        "docs_read": 113,
        "docs_written": 113,
        "changes_pending": 0,
        "doc_write_failures": 0,
        "checkpointed_source_seq": "113-g1AAAACTeJzLYWBgYMpgTmHgz8tPSTV0MDQy1zMAQsMckEQiQ1L9____szKYE01ygQLsZsYGqcamiZjKcRqRxwIkGRqA1H-oSbZgk1KMLCzTDE0wdWUBAF6HJIQ",
        "source_seq": "113-g1AAAACTeJzLYWBgYMpgTmHgz8tPSTV0MDQy1zMAQsMckEQiQ1L9____szKYE01ygQLsZsYGqcamiZjKcRqRxwIkGRqA1H-oSbZgk1KMLCzTDE0wdWUBAF6HJIQ",
        "through_seq": "113-g1AAAACTeJzLYWBgYMpgTmHgz8tPSTV0MDQy1zMAQsMckEQiQ1L9____szKYE01ygQLsZsYGqcamiZjKcRqRxwIkGRqA1H-oSbZgk1KMLCzTDE0wdWUBAF6HJIQ"
      },
      "error_count": 0,
      "last_updated": "2019-10-31T06:46:11Z",
      "start_time": "2019-10-31T06:42:16Z",
      "source_proxy": null,
      "target_proxy": null
    }
  ]
}

@nickva
Copy link
Contributor Author

nickva commented Oct 31, 2019

Example of _scheduler/jobs response:

{
    "jobs": [
        {
            "database": "_replicator",
            "doc_id": "2e5df7bf99f1a9d06feef6301300055f",
            "history": [
                {
                    "timestamp": "2019-10-31T06:46:11Z",
                    "type": "stopped"
                },
                {
                    "timestamp": "2019-10-31T06:42:16Z",
                    "type": "started"
                },
                {
                    "timestamp": "2019-10-31T06:42:16Z",
                    "type": "added"
                }
            ],
            "id": "d99e532c1129e9cacbf7ed085deca509+continuous",
            "info": {
                "changes_pending": 0,
                "checkpointed_source_seq": "113-g1AAAACTeJzLYWBgYMpgTmHgz8tPSTV0MDQy1zMAQsMckEQiQ1L9____szKYE01ygQLsZsYGqcamiZjKcRqRxwIkGRqA1H-oSbZgk1KMLCzTDE0wdWUBAF6HJIQ",
                "doc_write_failures": 0,
                "docs_read": 113,
                "docs_written": 113,
                "missing_revisions_found": 113,
                "revisions_checked": 113,
                "source_seq": "113-g1AAAACTeJzLYWBgYMpgTmHgz8tPSTV0MDQy1zMAQsMckEQiQ1L9____szKYE01ygQLsZsYGqcamiZjKcRqRxwIkGRqA1H-oSbZgk1KMLCzTDE0wdWUBAF6HJIQ",
                "through_seq": "113-g1AAAACTeJzLYWBgYMpgTmHgz8tPSTV0MDQy1zMAQsMckEQiQ1L9____szKYE01ygQLsZsYGqcamiZjKcRqRxwIkGRqA1H-oSbZgk1KMLCzTDE0wdWUBAF6HJIQ"
            },
            "node": "node1@127.0.0.1",
            "pid": null,
            "source": "http://adm:*****@localhost:15984/src/",
            "start_time": "2019-10-31T06:42:16Z",
            "target": "http://adm:*****@localhost:15984/tgt/",
            "user": null
        }
    ],
    "offset": 0,
    "total_rows": 1
}

@nickva nickva force-pushed the active-task-stats-in-scheduler branch from d1f7a95 to 4ca8bb9 Compare November 3, 2019 02:53
@nickva
Copy link
Contributor Author

nickva commented Nov 6, 2019

@nickva nickva force-pushed the active-task-stats-in-scheduler branch from 4ca8bb9 to f31b504 Compare November 6, 2019 14:57
@nickva nickva marked this pull request as ready for review November 6, 2019 14:57
@davisp
Copy link
Member

davisp commented Nov 6, 2019

Should we add your pending test you described as an actual test?

Previously `_scheduled/docs` returned detailed replication statistics for
completed jobs only. To get the same level of details from a running or pending
jobs users had to use `_active_tasks`, which is not optimal and required jumping
between monitoring endpoints.

`info` field was originally meant to hold these statistics but they were not
implemented and it just returned `null` as a placeholder. With work for 3.0
finalizing, this might be a good time to add this improvement to avoid
disturbing the API afterwards.

Just updating the `_scheduler/docs` was not quite enough since, replications
started from the `_replicate` endpoint would not be visible there and users
would still have to access `_active_tasks` to get inspect them, so let's add
the `info` field to the `_scheduler/jobs` as well.

After this update, all states and status details from `_active_tasks` and
`_replicator` docs should be available under `_scheduler/jobs` and
`_scheduler/docs` endpoints.
@nickva nickva force-pushed the active-task-stats-in-scheduler branch from f31b504 to c47c509 Compare November 6, 2019 18:29
@nickva
Copy link
Contributor Author

nickva commented Nov 6, 2019

@davisp Good idea. Added the test.

There was a test that already check active_tasks details were retained so modified to check that scheduler also has required fields both when it is running and pending.

Copy link
Member

@davisp davisp left a comment

Choose a reason for hiding this comment

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

+1

@nickva nickva merged commit ec23c34 into master Nov 6, 2019
@nickva nickva deleted the active-task-stats-in-scheduler branch November 6, 2019 22:55
nickva added a commit to apache/couchdb-documentation that referenced this pull request Nov 8, 2019
Recently "info" field for running and pending states switched to having
replication stats instead of being `null`, so update documentation accordingly.

Related PR: apache/couchdb#2292
nickva added a commit to apache/couchdb-documentation that referenced this pull request Nov 8, 2019
Recently "info" field for running and pending states switched to having
replication stats instead of being `null`, so update documentation accordingly.

Related PR: apache/couchdb#2292
nickva added a commit to apache/couchdb-documentation that referenced this pull request Nov 11, 2019
Recently "info" field for running and pending states switched to having
replication stats instead of being `null`, so update documentation accordingly.

Related PR: apache/couchdb#2292
cldocid2 pushed a commit to ibm-cloud-docs/Cloudant that referenced this pull request Nov 11, 2019
This mirrors the upstream CouchDB documentation:
apache/couchdb-documentation@051acd9

And the new feature introduced in:
apache/couchdb#2292
nickva added a commit to nickva/couchdb that referenced this pull request Sep 7, 2022
Recently "info" field for running and pending states switched to having
replication stats instead of being `null`, so update documentation accordingly.

Related PR: apache#2292
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.

None yet

2 participants