getting permission denied error while executing N1QL query on couchbase 7.1 if result set is big - couchbase

I am executing following query statement whose result set contains 10000 documents, while running the query I get permission denied error. If the result sets are small then this error does not come.
query
delete from `A` where _type="typeA" and tenant = "B" and status="ACTIVE"
From the above query 10000 records to be deleted
Following is the err
[
{
"code": 5000,
"msg": "open /data/tmp/scan-results428491556497897: permission denied - cause: open /tescodata/tmp/scan-results428491556497897: permission denied",
"query": "delete from `A` where _type=\"typeA\" and tenant = \"B\" and status=\"ACTIVE\""
},
{
"code": 5000,
"msg": " open /data/tmp/scan-results428491556497897: permission denied - cause: open /data/tmp/scan-results428491556497897: permission denied"
}
]
Here the CB version is 7.1

Make sure the following has read/write permissions
https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/backfill.html

Related

Node.js GraphQL API Stops working as soon as I deploy it: "Error validating datasource `db`: the URL must start with the protocol `mysql://"

I build a GraphQL API with Apollo and Prisma ORM which is connected to my hosted MySQL Database (The Database has already content in it).
When I run it on my localhost everything works fine and I can query the Database with GraphQL statements.
As soon as I deploy my node.js project to DigitalOcean (auto deployed with GitHub) it stops working and I get the following error:
{
"errors": [
{
"message": "\nInvalid `prisma.content.findMany()` invocation in\n/workspace/src/schema.js:36:29\n\n 33 const resolvers = {\n 34 Query: {\n 35 memes: (parent, args) => {\n→ 36 return prisma.content.findMany(\n error: Error validating datasource `db`: the URL must start with the protocol `mysql://`.\n --> schema.prisma:7\n | \n 6 | provider = \"mysql\"\n 7 | url = env(\"DATABASE_URL\")\n | \n\nValidation Error Count: 1",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"memes"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"clientVersion": "3.6.0",
"stacktrace": [
"Error: ",
"Invalid `prisma.content.findMany()` invocation in",
"/workspace/src/schema.js:36:29",
"",
" 33 const resolvers = {",
" 34 Query: {",
" 35 memes: (parent, args) => {",
"→ 36 return prisma.content.findMany(",
" error: Error validating datasource `db`: the URL must start with the protocol `mysql://`.",
" --> schema.prisma:7",
" | ",
" 6 | provider = \"mysql\"",
" 7 | url = env(\"DATABASE_URL\")",
" | ",
"",
"Validation Error Count: 1",
" at cb (/workspace/node_modules/#prisma/client/runtime/index.js:38689:17)",
" at processTicksAndRejections (internal/process/task_queues.js:97:5)"
]
}
}
}
],
"data": null
}
Here is my schema.prisma file:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
...
The only thing that is different from the hosted project compared to the local project is that I put .env file and node_modules on the .gitignore file.
So it seems like the project is accessing the wrong DATABASE_URL, but how should the hosted project know the DATABASE_URL in my .env file when the .env file is on .gitignore?
Here is what I do:
Change the DATABASE_URL in my .env file to my local MySQL Database hosted on a docker container
Run npx prisma migrate dev --preview-feature to generate the migration files
Run git add .
Run git commit -m "New Commit"
Run DATABASE_URL=mysql://censored:censored#censored:3306/censored npx prisma migrate resolve --applied "my_migration_folder_name" --preview-feature which succeeds and tells me "Migration my_migration_folder_name marked as applied."
Run git push
I can see that the Migration is successfully created on my MySQL Database but as soon as I run the app and try to query the database it gives me that error.
The code has to be correct because it is working on my localhost even when querying the hosted MySQL Database.
I also double checked that the Model in the schema.prisma file is in sync with my hosted MySQL Database schema.
I'm running out of ideas on what I could try.
EDIT
I actually think it has something to do with the environment variables I set in the settings of my DigitalOcean application.
Before it was set to:
envs:
- key: DATABASE_URL
scope: RUN_AND_BUILD_TIME
value: ${db.DATABASE_URL}
Now I set it to:
envs:
- key: DATABASE_URL
scope: RUN_AND_BUILD_TIME
value: mysql://censored:cesnored#censored:3306/censored
I thought that this will fix the problem but now it tells me that the connection fails because of wrong database credentials even though it is the right link with the right credentials.
I fixed it by clicking "Force rebuild and deploy" on my digitalOcean app.

Not able to create mysql user with AWSAuthenticationPlugin with terraform

I am trying to create a MySQL user to use with IAM, and I am using terraform to do this.
This is what I am trying to accomplish :
CREATE USER 'lambda' IDENTIFIED WITH AWSAuthenticationPlugin as 'RDS';
with
provider "mysql" {
alias = "kadamb-test"
endpoint = "${aws_db_instance.kadamb-test.endpoint}"
username = "${aws_db_instance.kadamb-test.username}"
password = "${aws_db_instance.kadamb-test.password}"
}
resource "mysql_user" "kadamb-test-iam-user" {
provider = "mysql.kadamb-test"
user = "kadamb_test_user"
host = "%"
auth_plugin = "AWSAuthenticationPlugin"
tls_option = ""
}
This is the output when I am running terraform-apply:
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
+ mysql_user.kadamb-test-iam-user
id: <computed>
auth_plugin: "AWSAuthenticationPlugin"
host: "%"
user: "kadamb_test_user"
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
mysql_user.kadamb-test-iam-user: Creating...
auth_plugin: "" => "AWSAuthenticationPlugin"
host: "" => "%"
user: "" => "kadamb_test_user"
Error: Error applying plan:
1 error(s) occurred:
* mysql_user.kadamb-test-iam-user: 1 error(s) occurred:
* mysql_user.kadamb-test-iam-user: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
I am reading the documentation and trying to debug what is going wrong, but couldn't find anything.
Can anyone help me with this?
Just changing tls_option = "" to tls_option = "NONE", solved my problem.
I am not sure, how and what difference did it make, but I was able to create the user with this.

neo4j apoc.export.csv permission denied error

I am trying to use apoc.export.csv
My query is as follows:
call apoc.export.csv.query("MATCH (a) Return id(a) limit 5", "test.csv", {} )
but i get this error:
Failed to invoke procedure 'apoc.export.csv.query': Caused by: java.io.FileNotFoundException: test.csv (Permission denied)
I have the following set in neo4j.conf
apoc.export.file.enabled=true
dbms.security.procedures.whitelist=apoc.export.*
any hints would be appreciated
exporting to /tmp/filename worked!

sails-mysql error handling : TypeError: Converting circular structure to JSON

Server: Sailsjs
Database: mysql
Node Library used: sails-mysql(0.11.5)
I am trying to insert a data in mysql from sailsjs node server.
Data to be inserted:
{
"first_name": "Admin Testing",
"last_name": "User",
"email": "admin14#testing.com",
"role_id": 8
}
Where role_id is having a foreign key relation to model role.
Here the role_id : 8 doesn't have value in role table. So while inserting, it is throwing the error. But that error we couldn't console or json.stringify since the following error occurs:
TypeError: Converting circular structure to JSON
at JSON.stringify (<anonymous>)
at /var/www/aitachatbot/server/api/controllers/UserController.js:38:42
at wrapper (/var/www/aitachatbot/server/node_modules/waterline/node_modules/lodash/index.js:3602:19)
at applyInOriginalCtx (/var/www/aitachatbot/server/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
at wrappedCallback (/var/www/aitachatbot/server/node_modules/waterline/lib/waterline/utils/normalize.js:331:16)
at error (/var/www/aitachatbot/server/node_modules/switchback/lib/normalize.js:42:31)
at _switch (/var/www/aitachatbot/server/node_modules/switchback/lib/factory.js:56:28)
at /var/www/aitachatbot/server/node_modules/sails-hook-validation/lib/create.js:66:21
at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/create.js:223:14
at wrapper (/usr/local/lib/node_modules/sails/node_modules/lodash/index.js:3592:19)
at applyInOriginalCtx (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
at wrappedCallback (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:335:16)
at error (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:42:31)
at _switch (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/factory.js:56:28)
at afterwards (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:87:16)
at wrapper (/usr/local/lib/node_modules/sails/node_modules/lodash/index.js:3592:19)
at applyInOriginalCtx (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
at wrappedCallback (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:335:16)
at error (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:42:31)
at _switch (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/factory.js:56:28)
at sendBackError (/var/www/aitachatbot/server/node_modules/sails-mysql/lib/connections/spawn.js:97:11)
at Object.poolfully [as releaseConnection] (/var/www/aitachatbot/server/node_modules/sails-mysql/lib/connections/release.js:28:12)
at /var/www/aitachatbot/server/node_modules/sails-mysql/lib/connections/spawn.js:90:37
at Query._callback (/var/www/aitachatbot/server/node_modules/sails-mysql/lib/adapter.js:395:27)
at Query.Sequence.end (/var/www/aitachatbot/server/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
at Query.ErrorPacket (/var/www/aitachatbot/server/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Query.js:94:8)
at Protocol._parsePacket (/var/www/aitachatbot/server/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:280:23)
at Parser.write (/var/www/aitachatbot/server/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Parser.js:73:12)
How can we handle this error in sailsjs?
In theory, you don't want these errors to ever show up in production... even if they did, the full json dump of the error object probably is not something a run-of-the-mill user wants to see.
You may also be asking about how to get full info out of this error while debugging. I guess the good news there is, you seem to already know the root cause of your error!
The error objects we have in node can have pretty different structures depending where they come from, but I have yet to encounter an error that does not have smart casting of the errors to strings. That means that even if console.log(err) fails, something like: console.log('Got an error: ' + err) will likely work, casting the error to a string.
The code could be something like this:
User.create({
"first_name": "Admin Testing",
"last_name": "User",
"email": "admin14#testing.com",
"role_id": 8
}).exec(function(err, createdUser) {
if (err) {
var readableErr = '' + err;
console.log('Error creating user: ' + readableErr);
// return something the client will recognize and interpret
// you can use http error codes, or your own conventions
return res.send({
success: false,
message: readableErr
});
}
// do something with createdUser...
});

Set-AzureRmVMADDomainExtension fails to add VM to AD Domain

The below VM extension fails to add VM to the domain.
It works fine when the ‘Computer Account’ exists in the AD. If the ‘Computer Account’ do not exist (New Server) it fails.
Set-AzureRmVMADDomainExtension -TypeHandlerVersion '1.0' -JoinOption 3 -DomainName $strDomainDNSName -ResourceGroupName $strRes_GrpName -VMName $strHostName -Credential $objCred -OUPath $strServerOU -Restart
The join option 3 should complete the below actions.
Value Meaning
NETSETUP_JOIN_DOMAIN
0x00000001 Joins the computer to a domain. If this value is not specified, joins the computer to a workgroup.
NETSETUP_ACCT_CREATE
0x00000002 Creates the account on the domain.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa370433(v=vs.85).aspx
Found the below error details under Azure VM Extension:
[
{
"code": "ComponentStatus/JoinDomainException for Option 3 meaning 'User Specified'/failed/1",
"displayStatus": "Provisioning failed",
"level": "Error",
"message": "ERROR - Failed to join domain='MyAd.ad.company.co.uk', ou='OU=Computers,DC=MyAd,DC=ad,DC=company,DC=co,DC=uk', user='LocalAdmin#MyAD.ad.company.co.uk', option='NetSetupJoinDomain, NetSetupAcctCreate' (#3 meaning 'User Specified'). Error code 2",
"time": null
}
{
"code": "ComponentStatus/JoinDomainException for Option 1 meaning 'User Specified without NetSetupAcctCreate'/failed/1",
"displayStatus": "Provisioning failed",
"level": "Error",
"message": "ERROR - Failed to join domain='MyAd.ad.company.co.uk', ou='OU=Computers,DC=MyAd,DC=ad,DC=company,DC=co,DC=uk', user='MGTAdmin#MyAd.ad.company.co.uk', option='NetSetupJoinDomain' (#1 meaning 'User Specified without NetSetupAcctCreate'). Error code 1332",
"time": null
}
]
Only the Built-in 'Computers' OU has the problem.
Tried both 'OU=Computers,DC=MyAd,DC=ad,DC=company,DC=co,DC=uk' and 'CN=Computers,DC=MyAd,DC=ad,DC=company,DC=co,DC=uk'. Failed with same Error.
But other user created OU works fine. For Eg. 'OU=TSTVLAN,OU=MGTServers,,DC=MyAd,DC=ad,DC=company,DC=co,DC=uk'
Mine was failing with "User Specified without NetSetupAcctCreate", error 1323 in the logs.
I needed to update the username to include the domain, ie
User= 'domainName\userName'
Then it worked.