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

SSL Config conflicts with secondary database #1133

Open
sheik-syed opened this issue Sep 22, 2020 · 3 comments
Open

SSL Config conflicts with secondary database #1133

sheik-syed opened this issue Sep 22, 2020 · 3 comments
Assignees
Labels

Comments

@sheik-syed
Copy link

@sheik-syed sheik-syed commented Sep 22, 2020


I am using two db both are Postgres. The first one is configured in .env and it is enabled SSL (called primary db). The second one is used for storing aggregation and disabled SSL on this (called secondary db).

Primary db configured in .env
.env
CUBEJS_DB_HOST=33.aaa.xx.yyy
CUBEJS_DB_NAME=sb_analytics
CUBEJS_DB_USER=system_sbs
CUBEJS_DB_PASS=password
CUBEJS_WEB_SOCKETS=true
CUBEJS_DB_TYPE=postgres
CUBEJS_DB_SSL=true
CUBEJS_DB_SSL_REJECT_UNAUTHORIZED=false
CUBEJS_API_SECRET=d0af34c14086b2fc4911b244dadc224211c9f78a0c29422666408f8ddc04fd44512793bfaad45845d75412da594969360f6f0b578f1bb714bb768912d5863f45

Secondary db configuration configured in index.js
index.js
const CubejsServer = require("@cubejs-backend/server");
const PgSQLDriver = require('@cubejs-backend/postgres-driver');

const server = new CubejsServer({
externalDbType: 'postgres',
externalDriverFactory: () => new PgSQLDriver({
host: 'localhost',
database: 'cube2',
user: 'postgres',
password: 'postgress',
port: '5432',
ssl: false(i am not sure this once is correct or not)
})
});

Schema:
cube(QueryLogs, {
sql: SELECT * FROM public.query_logs,
joins: {
},
measures: {
count: {
type: count,
drillMembers: [collectionName, customerId, createdDate]
}
},
dimensions: {
collectionName: {
sql: collection_name,
type: string
},
customerId: {
sql: customer_id,
type: string
},
ip: {
sql: ip,
type: string
},
query: {
sql: query,
type: string
},
createdDate: {
sql: created_date,
type: time
}
},
preAggregations: {
custQueryCount: {
type: rollup,
measureReferences: [QueryLogs.count],
timeDimensionReference: QueryLogs.createdDate,
granularity: month,
external: true
}
}
});

===========================================================
I am facing below error while cube-js trying to create a table on secondary db.

Error while querying: ab90fae9-94cb-4da9-821d-a8c790bdb65a-span-1 (3809ms)
{
"processingId": 1,
"queueSize": 1,
"queryKey": [
[
"CREATE TABLE stb_pre_aggregations.query_logs_cust_query_count AS SELECT\n date_trunc('month', ("query_logs".created_date::timestamptz AT TIME ZONE 'UTC')) "query_logs__created_date_month", count(*) "query_logs__count"\n FROM\n public.query_logs AS "query_logs"\n GROUP BY 1",
[]
],
[
[
{
"max": "2020-09-08T10:31:43.644"
}
]
]
],
"queuePrefix": "SQL_PRE_AGGREGATIONS_STANDALONE_default",
"timeInQueue": 0
}
error: at or near "if": syntax error: unimplemented: this syntax
at Parser.parseErrorMessage (/Users/sheik/SSS/cube-js/testme/test7/node_modules/pg-protocol/dist/parser.js:278:15)
at Parser.handlePacket (/Users/sheik/SSS/cube-js/testme/test7/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/Users/sheik/SSS/cube-js/testme/test7/node_modules/pg-protocol/dist/parser.js:39:38)
at TLSSocket.stream.on (/Users/sheik/SSS/cube-js/testme/test7/node_modules/pg-protocol/dist/index.js:8:42)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at TLSSocket.Readable.push (_stream_readable.js:208:10)
at TLSWrap.onread (net.js:597:20)

===========================================================

Primary db ssl configuration conflicts with secondary db.
what are the configurations used for disabling SSL in index.js file (externalDriverFactory)

@RusovDmitriy
Copy link
Contributor

@RusovDmitriy RusovDmitriy commented Sep 23, 2020

Hi @sheik-syed! You can see a description of options for PgSQLDriver on the following links:

https://node-postgres.com/features/ssl
https://node-postgres.com/api/pool

@sheik-syed
Copy link
Author

@sheik-syed sheik-syed commented Sep 23, 2020

Hi @sheik-syed! You can see a description of options for PgSQLDriver on the following links:

https://node-postgres.com/features/ssl
https://node-postgres.com/api/pool

Yes. But i want to disable ssl configuration in index.js file. .env file configuration(see above) conflicts with index.js db connection.
index.js
const server = new CubejsServer({
externalDbType: 'postgres',
externalDriverFactory: () => new MySQLDriver({
host: 'localhost',
database: 'cube2',
user: 'postgres',
password: 'postgress',
port: '5432'
})
});

I see the below error for the above config. secondary doesnt enabled ssl. I want to disable from config. how can i do that?

error
Error while querying: 60567ea8-0808-4ed2-9b47-117c21924138-span-1 (4ms)
{
"processingId": 2,
"queueSize": 1,
"queryKey": "Fetch tables for stb_pre_aggregations",
"queuePrefix": "SQL_PRE_AGGREGATIONS_CACHE_STANDALONE_default",
"timeInQueue": 1
}
Error: The server does not support SSL connections
at Socket. (/Users/sheik/SSS/cube-js/testme/test7/node_modules/pg/lib/connection.js:72:37)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:597:20)
Error querying db: 60567ea8-0808-4ed2-9b47-117c21924138-span-1

@RusovDmitriy
Copy link
Contributor

@RusovDmitriy RusovDmitriy commented Sep 27, 2020

You can disable SSL just set the value as false., it overwrites any values from the .env file.

const server = new CubejsServer({
  externalDbType: 'postgres',
  externalDriverFactory: () => new PgSQLDriver({
     ...,   
     ssl: false
 })
});

Your first error no related SSL. Which version cube.js you used? Could you please provide SQL query for CREATE TABLE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.