Skip to content

Conversation

@kanwarujjaval
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This work-in-progress PR introduces ClickHouse cluster, replication, and high availability support to Countly. The changes focus on configuration, cluster-aware mutation management, and improved development tooling.

Key changes:

  • Added comprehensive ClickHouse cluster configuration with support for sharding, replication, and HA modes
  • Modified mutation validation logic to handle cluster mode with _local table suffixes
  • Cleaned up extensive debug logging in API startup, converting console.log calls to structured logging

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
package.json Added dev start scripts with symlink support and ClickHouse cluster test script
api/jobs/mutationManagerJob.js Added cluster-aware mutation validation logic using ClusterManager to determine appropriate table names
api/configextender.js Added documentation comments explaining ClickHouse configuration override mechanism
api/config.sample.js Added extensive ClickHouse cluster, replication, dictionary, and identity configuration sections
api/api.js Removed debug console.log statements and replaced with structured log utility calls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

common.drillQueryRunner = granuralQueries;
if (common.drillDb) {
common.drillReadBatcher = new ReadBatcher(common.drillDb, {configs_db: common.db});
console.log('✓ Drill database components initialized');
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

Leftover console.log statement that should be converted to use the log utility like the rest of the file. This is inconsistent with the cleanup done in the rest of this file where console.log statements were replaced with log.* methods.

Suggested change
console.log('✓ Drill database components initialized');
log.d('✓ Drill database components initialized');

Copilot uses AI. Check for mistakes.
Comment on lines +326 to +336
if (ClusterManager) {
try {
const cm = new ClusterManager(countlyConfig.clickhouse || {});
if (cm.isClusterMode()) {
validationTable = task.collection + '_local';
}
}
catch (e) {
log.w('Could not determine cluster mode for validation table', e?.message);
}
}
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The ClusterManager is instantiated inside a loop for every task being processed. This is inefficient and could impact performance when processing many mutation tasks. The cluster mode determination should be done once before the loop, either as a class property or by checking once at the start of the method.

Copilot uses AI. Check for mistakes.
}
console.log('=== END DATABASE CONFIG CHECK ===');

// Finaly set the visible title
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

Typo in comment: "Finaly" should be "Finally".

Suggested change
// Finaly set the visible title
// Finally set the visible title

Copilot uses AI. Check for mistakes.
},
// Identity configuration for user merging and dictionary data retention
identity: {
daysOld: 30 // Number of days after which identity mappings are baked into cold partitions.
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

Missing comma after the daysOld property. This will cause a syntax error when parsing the configuration file. A comma is required after object properties in JavaScript.

Suggested change
daysOld: 30 // Number of days after which identity mappings are baked into cold partitions.
daysOld: 30, // Number of days after which identity mappings are baked into cold partitions.

Copilot uses AI. Check for mistakes.
if (common.drillDb) {
common.drillReadBatcher = new ReadBatcher(common.drillDb, {configs_db: common.db});
console.log('✓ Drill database components initialized');
common.drillReadBatcher = new ReadBatcher(common.drillDb);
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The common.drillReadBatcher is initialized twice. Line 48 creates it with configuration options {configs_db: common.db}, but then line 50 immediately overwrites it without those options. This appears to be a merge error or leftover debug code. The second initialization should be removed, or if the configuration options are no longer needed, only the first initialization should be removed.

Suggested change
common.drillReadBatcher = new ReadBatcher(common.drillDb);

Copilot uses AI. Check for mistakes.
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.

3 participants