Thank you for your interest in contributing to pgbalancer! We welcome contributions from the community.
If you find a bug or have a feature request:
- Check if the issue already exists in GitHub Issues
- If not, create a new issue with:
- Clear description of the problem or feature
- PostgreSQL version and OS information
- pgbalancer version and configuration
- Steps to reproduce (for bugs)
- Expected vs actual behavior
- Relevant log excerpts or error messages
- Fork the repository
- Create a branch for your changes:
git checkout -b feature/your-feature-name
- Make your changes following our coding standards
- Test thoroughly:
./configure --with-pgsql=/usr/local/pgsql make sudo make install # Run tests cd src/test && ./run-tests.sh
- Commit with clear messages:
git commit -m "Add feature: description of feature" - Push to your fork:
git push origin feature/your-feature-name
- Open a Pull Request with:
- Clear description of changes
- Why the change is needed
- How it was tested
- Any breaking changes or migration notes
Follow PostgreSQL C coding conventions:
- Variables: Declare at the start of functions
- Comments: Use C-style
/* */comments (not//) - Braces: Allman style (opening brace on its own line for functions)
- Indentation: Tabs (width 4)
- Naming: Snake_case for functions and variables
- Headers: Include guards in all
.hfiles - Warnings: Code must compile with zero warnings
- Memory: Use pgbalancer memory contexts properly
Example:
void
pool_my_function(int param1, char *param2)
{
int result;
char *buffer;
/* Initialize variables */
result = 0;
buffer = palloc(256);
/* Function logic here */
pfree(buffer);
}- Update both YAML and .conf format parsers
- Add documentation in
doc/src/sgml/ - Update sample configurations in
src/sample/ - Test backward compatibility
- Document new endpoints in REST API reference
- Follow existing JSON response formats
- Add authentication if accessing sensitive data
- Update
bctlCLI tool if needed
pgbalancer/
├── src/
│ ├── main/ # Core pgbalancer logic
│ ├── protocol/ # Protocol handlers
│ ├── watchdog/ # Watchdog and failover
│ ├── rest_api/ # REST API server
│ ├── ai/ # AI load balancing
│ ├── config/ # Configuration parser
│ ├── utils/ # Utility functions
│ └── test/ # Test suite
├── bctl/ # CLI client tool
├── doc/ # SGML documentation
├── monitoring/ # Prometheus/Grafana
└── sample/ # Sample configurations
- PostgreSQL 13+ with development headers
- GCC or Clang compiler
- Autotools (autoconf, automake, libtool)
- libyaml
- libpq
- Git
# Clone repository
git clone https://github.com/pgelephant/pgbalancer.git
cd pgbalancer
# Configure
./configure \
--with-pgsql=/usr/local/pgsql \
--enable-rest-api \
--with-openssl
# Build
make
# Install
sudo make install
# Verify
pgbalancer --version
bctl --version# Run integration tests
cd src/test
./run-tests.sh
# Test specific feature
./test-failover.sh
./test-load-balance.sh
# Test REST API
curl http://localhost:8080/api/v1/statusIf your changes affect user-facing functionality:
- Update
README.md - Update SGML docs in
doc/src/sgml/ - Update REST API documentation
- Update
bctlhelp text - Update
CHANGELOG.md
cd doc/src
make html
# Output in doc/src/sgml/html/- All PRs require maintainer review
- CI/CD checks must pass
- At least one approval required
- No merge conflicts
- Documentation updated as needed
- Tests passing
- Add to
src/config/pool_config_variables.c - Add to
src/include/pool_config.h - Update config parser in
src/config/pool_config.c - Add documentation in
doc/src/sgml/config.sgml - Add to sample configs in
src/sample/ - Write tests
- Add handler in
src/rest_api/ - Register endpoint in router
- Update
bctlif needed - Document in REST API reference
- Add authentication if sensitive
- Write tests
- Implement in
src/watchdog/ - Add configuration parameters
- Update watchdog documentation
- Test failover scenarios
- Add integration tests
- Questions: Open a GitHub Discussion
- Bugs: Create an Issue
- Security: Email security@pgelephant.org
- General: Email team@pgelephant.org
Be respectful, professional, and collaborative. We follow the PostgreSQL Community Code of Conduct.
By contributing, you agree that your contributions will be licensed under the same terms as pgbalancer (PostgreSQL License). See COPYING for details.
Thank you for contributing to pgbalancer! 🙏