Submitted patches can include bug fixes, changes to the Java code base, improvements for tooling (both Java or Python), documentation, testing or any other changes that requires changing the code base. Although the process of contributing code is always the same, the amount of work and time it takes to get a patch accepted also depends on the kind of issue you’re addressing.
Not sure what to work? Just pick an issue marked as Low Hanging Fruit Complexity in JIRA, which we use to flag issues that could turn out to be good starter tasks for beginners.
Although contributions are highly appreciated, we do not guarantee that each contribution will become a part of Cassandra. Therefore it’s generally a good idea to first get some feedback on the things you plan to work on, especially about any new features or major changes to the code base. You can reach out to other developers on the mailing list or Slack.
There are currently multiple Cassandra versions maintained in individual branches:
|4.0||Code freeze (see below)|
|3.11||Critical bug fixes only|
|3.0||Critical bug fixes only|
|2.2||Critical bug fixes only|
|2.1||Critical bug fixes only|
Corresponding branches in git are easy to recognize as they are named
trunk branch is an exception, as it contains the most recent commits from all other branches and is used for creating new branches for future tick-tock releases.
Patches for new features are currently not accepted for 4.0 or any earlier versions. Starting with the code freeze in September, all efforts should focus on stabilizing the 4.0 branch before the first official release. During that time, only the following patches will be considered for acceptance:
- Bug fixes
- Measurable performance improvements
- Changes not distributed as part of the release such as:
- Testing related improvements and fixes
- Build and infrastructure related changes
Creating patches for bug fixes is a bit more complicated as this will depend on how many different versions of Cassandra are affected. In each case, the order for merging such changes will be
trunk. But don’t worry, merging from 2.1 would be the worst case for bugs that affect all currently supported versions, which isn’t very common. As a contributor, you’re also not expected to provide a single patch for each version. What you need to do however is:
- Be clear about which versions you could verify to be affected by the bug
- For 2.x: ask if a bug qualifies to be fixed in this release line, as this may be handled on case by case bases
- If possible, create a patch against the lowest version in the branches listed above (e.g. if you found the bug in 3.9 you should try to fix it already in 3.0)
- Test if the patch can be merged cleanly across branches in the direction listed above
- Be clear which branches may need attention by the committer or even create custom patches for those if you can
So you’ve finished coding and the great moment arrives: it’s time to submit your patch!
- Create a branch for your changes if you haven’t done already. Many contributors name their branches based on ticket number and Cassandra version, e.g.
git checkout -b 12345-3.0
- Verify that you follow Cassandra’s Code Style
- Make sure all tests (including yours) pass using ant as described in Testing. If you suspect a test failure is unrelated to your change, it may be useful to check the test’s status by searching the issue tracker or looking at CI results for the relevant upstream version. Note that the full test suites take many hours to complete, so it is common to only run specific relevant tests locally before uploading a patch. Once a patch has been uploaded, the reviewer or committer can help setup CI jobs to run the full test suites.
- Consider going through the Review Checklist for your code. This will help you to understand how others will consider your change for inclusion.
- Don’t make the committer squash commits for you in the root branch either. Multiple commits are fine - and often preferable - during review stage, especially for incremental review, but once +1d, do either:
- Attach a patch to JIRA with a single squashed commit in it (per branch), or
- Squash the commits in-place in your branches into one
- Include a CHANGES.txt entry (put it at the top of the list), and format the commit message appropriately in your patch ending with the following statement on the last line:
patch by X; reviewed by Y for CASSANDRA-ZZZZZ
- When you’re happy with the result, create a patch:git add <any new or modified file> git commit -m '<message>' git format-patch HEAD~1 mv <patch-file> <ticket-branchname.txt> (e.g. 12345-trunk.txt, 12345-3.0.txt)
Alternatively, many contributors prefer to make their branch available on GitHub. In this case, fork the Cassandra repository on GitHub and push your branch:git push --set-upstream origin 12345-3.0
- To make life easier for your reviewer/committer, you may want to make sure your patch applies cleanly to later branches and create additional patches/branches for later Cassandra versions to which your original patch does not apply cleanly. That said, this is not critical, and you will receive feedback on your patch regardless.
- Attach the newly generated patch to the ticket/add a link to your branch and click “Submit Patch” at the top of the ticket. This will move the ticket into “Patch Available” status, indicating that your submission is ready for review.
- Wait for other developers or committers to review it and hopefully +1 the ticket (see Review Checklist). If your change does not receive a +1, do not be discouraged. If possible, the reviewer will give suggestions to improve your patch or explain why it is not suitable.
- If the reviewer has given feedback to improve the patch, make the necessary changes and move the ticket into “Patch Available” once again.
Once the review process is complete, you will receive a +1. Wait for a committer to commit it. Do not delete your branches immediately after they’ve been committed - keep them on GitHub for a while. Alternatively, attach a patch to JIRA for historical record. It’s not that uncommon for a committer to mess up a merge. In case of that happening, access to the original code is required, or else you’ll have to redo some of the work.