-
Notifications
You must be signed in to change notification settings - Fork 980
[WIP] ch cluster+replica+ha #7111
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
base: newarchitecture
Are you sure you want to change the base?
Changes from all commits
7e0f2c5
8586e9c
6e86a35
437bf57
9676c37
3afc1cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,18 +16,6 @@ const moment = require("moment"); | |||||
| const tracker = require('./parts/mgmt/tracker.js'); | ||||||
| require("./init_configs.js"); | ||||||
|
|
||||||
| // EXTENSIVE DEBUGGING - Print configuration | ||||||
| console.log('=== COUNTLY API STARTUP DEBUG ==='); | ||||||
| console.log('Process ENV SERVICE_TYPE:', process.env.SERVICE_TYPE); | ||||||
| console.log('Config loaded:', !!countlyConfig); | ||||||
| console.log('Config keys:', Object.keys(countlyConfig)); | ||||||
| console.log('Full config:', JSON.stringify(countlyConfig, null, 2)); | ||||||
| console.log('API config:', JSON.stringify(countlyConfig.api, null, 2)); | ||||||
| console.log('MongoDB config:', JSON.stringify(countlyConfig.mongodb, null, 2)); | ||||||
| console.log('ClickHouse config:', JSON.stringify(countlyConfig.clickhouse, null, 2)); | ||||||
| console.log('Logging config:', JSON.stringify(countlyConfig.logging, null, 2)); | ||||||
| console.log('=== END CONFIG DEBUG ==='); | ||||||
|
|
||||||
| var granuralQueries = require('./parts/queries/coreAggregation.js'); | ||||||
|
|
||||||
| //Add deletion manager endpoint | ||||||
|
|
@@ -36,24 +24,16 @@ require('./utils/mutationManager.js'); | |||||
| var t = ["countly:", "api"]; | ||||||
| common.processRequest = processRequest; | ||||||
|
|
||||||
| console.log("Starting Countly", "version", versionInfo.version, "package", pack.version); | ||||||
| console.log('=== DATABASE CONFIG CHECK ==='); | ||||||
| console.log('countlyConfig.mongodb:', JSON.stringify(countlyConfig.mongodb, null, 2)); | ||||||
| console.log('frontendConfig.mongodb:', JSON.stringify(frontendConfig.mongodb, null, 2)); | ||||||
| log.i("Starting Countly", "version", versionInfo.version, "package", pack.version); | ||||||
| if (!common.checkDatabaseConfigMatch(countlyConfig.mongodb, frontendConfig.mongodb)) { | ||||||
| log.w('API AND FRONTEND DATABASE CONFIGS ARE DIFFERENT'); | ||||||
| console.log('WARNING: Database configs do not match!'); | ||||||
| } | ||||||
| console.log('=== END DATABASE CONFIG CHECK ==='); | ||||||
|
|
||||||
| // Finaly set the visible title | ||||||
| process.title = t.join(' '); | ||||||
|
|
||||||
| console.log('=== CONNECTING TO DATABASES ==='); | ||||||
| plugins.connectToAllDatabases().then(function() { | ||||||
| console.log('✓ Database connection successful'); | ||||||
| console.log('common.db available:', !!common.db); | ||||||
| console.log('common.drillDb available:', !!common.drillDb); | ||||||
| log.d('Database connection successful'); | ||||||
|
|
||||||
| plugins.loadConfigs(common.db, function() { | ||||||
| tracker.enable(); | ||||||
|
|
@@ -62,21 +42,18 @@ plugins.connectToAllDatabases().then(function() { | |||||
| common.readBatcher = new ReadBatcher(common.db); | ||||||
| common.insertBatcher = new InsertBatcher(common.db); | ||||||
| common.queryRunner = new QueryRunner(); | ||||||
| console.log('✓ Batchers and QueryRunner initialized'); | ||||||
|
|
||||||
| common.drillQueryRunner = granuralQueries; | ||||||
| if (common.drillDb) { | ||||||
| common.drillReadBatcher = new ReadBatcher(common.drillDb, {configs_db: common.db}); | ||||||
| console.log('✓ Drill database components initialized'); | ||||||
|
||||||
| console.log('✓ Drill database components initialized'); | |
| log.d('✓ Drill database components initialized'); |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
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.
| common.drillReadBatcher = new ReadBatcher(common.drillDb); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,16 @@ catch { | |
| // | ||
| } | ||
|
|
||
| let ClusterManager = null; | ||
| try { | ||
| ClusterManager = require('../../plugins/clickhouse/api/managers/ClusterManager'); | ||
| } | ||
| catch { | ||
| // ClusterManager not available (clickhouse plugin not loaded) | ||
| } | ||
|
|
||
| const countlyConfig = require('../config'); | ||
|
|
||
| /** | ||
| * Normalize mutation manager job configuration values | ||
| * @param {Object} cfg - Raw configuration object from the DB | ||
|
|
@@ -311,7 +321,20 @@ class MutationManagerJob extends Job { | |
| for (const task of awaiting) { | ||
| try { | ||
| if (chHealth && typeof chHealth.getMutationStatus === 'function') { | ||
| const status = await chHealth.getMutationStatus({ validation_command_id: task.validation_command_id, table: task.collection, database: task.db }); | ||
| // In cluster mode, mutations target _local tables, so validation must check _local | ||
| let validationTable = task.collection; | ||
| 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); | ||
| } | ||
| } | ||
|
Comment on lines
+326
to
+336
|
||
| const status = await chHealth.getMutationStatus({ validation_command_id: task.validation_command_id, table: validationTable, database: task.db }); | ||
| if (status && status.is_done) { | ||
| await common.db.collection("mutation_manager").updateOne( | ||
| { _id: task._id }, | ||
|
|
||
There was a problem hiding this comment.
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".