MongoDB — Which Authentication Database should I use when creating users - database

In Current Mongo Instance
Following the Mongo Best Practices : Users are created in system database(Admin) rather than respective database and made admin database as authorization database
But creating users in system database (admin) works fine when tested in standalone functions when checked with code(Docker) getting exceptions
Also before creating user used the command
switch to admin
connection string used:
mongodb:// :#xxxxxxx:27017/admin
Caused by: com.mongodb.MongoCommandException: Command failed with
error 263 (OperationNotSupportedInTransaction): 'Cannot run command
against the 'admin' database in a transaction.' on server xxxxxxxxxxx.
The full response is {"operationTime": {"$timestamp": {"t":
1649307185, "i": 1}}, "ok": 0.0, "errmsg": "Cannot run command against
the 'admin' database in a transaction.", "code": 263, "codeName":
"OperationNotSupportedInTransaction", "$clusterTime": {"clusterTime":
{"$timestamp": {"t": 1649307185, "i": 1}}, "signature": {"hash":
{"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType":
"00"}}, "keyId": 0}}}

Related

Database Errors while running dbt run

I am new to dbt and I am trying to run dbt from cli, which is connected to snowflake. I have successfully created a profile.yml, dbt_profile.yml and dbt debug shows everything is connected. but when I run dbt run to create the example models I get this error
Running with dbt=1.0.1
Found 2 models, 4 tests, 0 snapshots, 0 analyses, 179 macros, 0 operations, 0 seed files, 0 sources, 0 exposures, 0 metrics
Encountered an error:
Runtime Error
Database error while listing schemas in database "LEE_Test"
Database Error
002043 (02000): SQL compilation error:
Object does not exist, or operation cannot be performed.
okay there might be a problems in your dbt profile in which u have given the snowflake detials there is some mistake there probably in naming or either
here is an exmaple on how you can connect to snowflake
default:(profile name )
outputs:
dev: # User-Password config
type: snowflake
account: snowflake_account_link
user: DBT_CLOUD_DEV
password: *******
role: your role of snowflake
database: your data base name
warehouse: name of your warehouse
schema: <your schema name >
threads: 2
client_session_keep_alive: False
target: dev
let me know if this works or not

How do I keep track of progress of a Cloudant replication?

If I have an IBM Cloudant database with around one million documents in it and I set up a replication process to copy this data to another region, how can I tell how far the replication job has progressed? I know when it starts and when it has finished, but nothing in between. Is there a way to track progress?
If the target database was empty at the start of the replication, and there's no other changes being written to the target, then it's a case of waiting until the sequence token of the target database matches the sequence token of the source.
You can find the current sequence token of a database by using the GET /<database name> endpoint on the source & the target e.g.
curl $URL/sourcedb
{
"update_seq": "23600-g1AAAARXeJyd0",
"db_name": "sourcedb",
...
}
In the above example, there are 23600 changes that the replicator needs to work through. The same command can be run against the target database to see the progress of replication.
Alternatively, there is an API endpoint that allows you to view the replication job's progress: GET _scheduler/docs/_replicator/<replication id> where the replication id is the _id of the document in the _replicator database that was created to initiate the replication.
It returns an object like this:
{
"database": "_replicator",
"doc_id": "e0330b1936f6194da22af8fa663c5be8",
"id": null,
"source": "https://source.cloudant.com/sourcedb/",
"target": "https://target.cloudant.com/targetdb/",
"state": "completed",
"error_count": 0,
"info": {
"revisions_checked": 1005,
"missing_revisions_found": 1005,
"docs_read": 1005,
"docs_written": 1005,
"changes_pending": 376,
"doc_write_failures": 0,
"checkpointed_source_seq": "1011-g1AAAAfLeJy91FFKwzAYwPGigo_uBvqq0JmkbZqCsomoj3oDzZcvZYxtFbc96w30BnoDvYHeQG-gN9AbzCYpbntbhfQlhdJ"
},
"start_time": "2020-11-17T09:55:01Z",
"last_updated": "2020-11-17T09:55:58Z"
}
which includes the status of the replication, how many documents have been processed and the last checkpointed sequence token, which should be enough to estimate progress of the replication job.
The full details of the API call are here.

Migration from v6.4 to v7.2 fails with "Column 'execution_id' cannot be null"

Running migration in a docker kiwitcms/kiwi:latest (v7.2 digest d757b56bc10c) image based docker container.
During migration testcases.0010_remove_bug fails with some database constraint problem.
Is this a bug in the migration script or an issue with data not consistent?
Operations to perform:
Apply all migrations: admin, attachments, auth, bugs, contenttypes, core, django_comments, kiwi_auth, linkreference, management, sessions, sites, testcases, testplans, testruns
Running migrations:
Applying testcases.0010_remove_bug...Traceback (most recent call last):
File "/venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 209, in execute
res = self._query(query)
File "/venv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 315, in _query
db.query(q)
File "/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 239, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1048, "Column 'execution_id' cannot be null")
This is a bug in the migration script. The problem lies in the fact that prior to these changes you could attach bugs directly to test cases, without an actual test execution. This resulted in the case_run_id field being None.
With the new changes bugs can only be attached to test executions and their execution_id field should always have a value.
Can you try this patch and let me know if it works for you:
https://github.com/kiwitcms/Kiwi/pull/1266

WSO2 Message Broker Error while adding Queue - Invalid Object Name

I have just set up a WSO2 Message Broker 3.0.0 connecting to a SQL Server DB.
The DB for the Carbon MB component has been created successfully as well.
The DB for the Message Broker Data store is created and contains the table MB_QUEUE_MAPPING.
However when adding a Queue via the MB UI I see the following error in the stack trace:
[2015-12-16 15:00:41,472] ERROR {org.wso2.andes.store.rdbms.RDBMSMessageStoreImpl} - Error occurred while retrieving destination queue id for destina
tion queue TestQ
java.sql.SQLException: Invalid object name 'MB_QUEUE_MAPPING'.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2988)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2421)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:671)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:505)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:1029)
at org.wso2.andes.store.rdbms.RDBMSMessageStoreImpl.getQueueID(RDBMSMessageStoreImpl.java:1324)
at org.wso2.andes.store.rdbms.RDBMSMessageStoreImpl.getCachedQueueID(RDBMSMessageStoreImpl.java:1298)
at org.wso2.andes.store.rdbms.RDBMSMessageStoreImpl.addQueue(RDBMSMessageStoreImpl.java:1634)
at org.wso2.andes.store.FailureObservingMessageStore.addQueue(FailureObservingMessageStore.java:445)
at org.wso2.andes.kernel.AMQPConstructStore.addQueue(AMQPConstructStore.java:116)
at org.wso2.andes.kernel.AndesContextInformationManager.createQueue(AndesContextInformationManager.java:154)
at org.wso2.andes.kernel.disruptor.inbound.InboundQueueEvent.updateState(InboundQueueEvent.java:151)
at org.wso2.andes.kernel.disruptor.inbound.InboundEventContainer.updateState(InboundEventContainer.java:167)
at org.wso2.andes.kernel.disruptor.inbound.StateEventHandler.onEvent(StateEventHandler.java:67)
at org.wso2.andes.kernel.disruptor.inbound.StateEventHandler.onEvent(StateEventHandler.java:41)
at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:128)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
The "Add Queue" screen does not go away however the Queue does get added to the MB_QUEUE table just fine in the DB. Both tables MB_QUEUE_MAPPING & MB_QUEUE_COUNTER are blank.
The "List Queues" screen does blank despite a number of Queues in the MB_QUEUE table. Stack trace also shows errors but is not included as its not relevant to the error above.
I can create a Topic just fine however.
I want to know why MB would say the table MB_QUEUE_MAPPING is an Invalid object name when the table clearly exists ?
I suspect the way you have configure the mysql database is incorrect.So you can better try out one of these below two scenarios to make sure about this issue.
1) starting the server for the first time with the -Dsetup parameter or
2) you can refer the documentation(https://docs.wso2.com/display/MB300/Configuring+MySQL) "Configuring MySQL" and follow step by step instructions given in order.
I have tried out the second scenario and I did not get any exception when I am adding queue.And the document I have mentioned will have to be update as below.
you can see this command in the step 3.
mysql -u <db_user_name> -p -D<database_name> < '<WSO2MB_HOME>/dbscripts/mb-store/mysql-mb.sql ';
db_user_name - username of db.
database_name - database name that you have created in the step 1.
WSO2MB_HOME - home directory path for MB.
Hope this could help you to resolve this issue.
It seems user connecting to MSSQL database not having correct permission. Most probably SELECT permission. Reason why I am saying is, when you adding queue, it does get added. This means user has INSERT permission. Once queue added, page redirected to Queue List page. User must have SELECT permission to retrieve queue list. Topic are not getting added to database, it keeps in registry. You can verify user who connecting to MSSQL from configuration like below in wso2mb-3.0.0/repository/conf/datasources/master-datasources.xml.
<datasource>
   <name>WSO2_MB_STORE_DB</name>
   <jndiConfig>
       <name>WSO2MBStoreDB</name>
   </jndiConfig>
   <definition type="RDBMS">
         <configuration>
                    <url>jdbc:jtds:sqlserver://localhost:1433/wso2_mb</url>
                    <username>sa</username>
                    <password>sa</password>
                    <driverClassName>net.sourceforge.jtds.jdbc.Driver</driverClassName>
                    <maxActive>200</maxActive>
                    <maxWait>60000</maxWait>
                    <minIdle>5</minIdle>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                    <defaultAutoCommit>false</defaultAutoCommit>
         </configuration>
     </definition>
</datasource>

Apache Drill 1.2 and SQL Server JDBC

Apache Drill 1.2 adds the exciting feature of including JDBC relational sources in your query. I would like to include Microsoft SQL Server.
So, following the docs I copied the SQL Server jar sqldjbc42.jar (the most recent MS JDBC driver) into the proper 3rd party directory.
I successfully added the storage.
The configuration is:
{
"type": "jdbc",
"driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"url": "jdbc:sqlserver://myservername",
"username": "myusername",
"password": "mypassword",
"enabled": true
}
as "mysqlserverstorage"
However, running queries fails. I've tried:
select * from mysqlserverstorage.databasename.schemaname.tablename
(of course I've use real existing tables instead of the placeholders here)
Error:
org.apache.drill.common.exceptions.UserRemoteException: VALIDATION ERROR: From line 2, column 6 to line 2, column 17: Table 'mysqlserverstorage.databasename.schemaname.tablename' not found [Error Id: f5b68a73-973f-4292-bdbf-54c2b6d5d21e on PC1234:31010]
and
select * from mysqlserverstorage.`databasename.schemaname.tablename`
Error:
org.apache.drill.common.exceptions.UserRemoteException: VALIDATION ERROR: Exception while reading tables [Error Id: 213772b8-0bc7-4426-93d5-d9fcdd60ace8 on PC1234:31010]
Has anyone had success in configuring and using this new feature?
Success has been reported using a storage plugin configuration, such as
{
type: "jdbc",
enabled: true,
driver: "com.microsoft.sqlserver.jdbc.SQLServerDriver",
url:"jdbc:sqlserver://172.31.36.88:1433;databaseName=msdb",
username:"root",
password:"<password>"
}
on pre-release Drill 1.3 and using sqljdbc41.4.2.6420.100.jar.
Construct you query as,
select * from storagename.schemaname.tablename
This will work with sqljdbc4.X as it works for me.

Resources