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

SQL: Async SQL command inside async HTTP command fails #1537

Closed
gramian opened this issue Apr 4, 2024 · 5 comments
Closed

SQL: Async SQL command inside async HTTP command fails #1537

gramian opened this issue Apr 4, 2024 · 5 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@gramian
Copy link
Collaborator

gramian commented Apr 4, 2024

ArcadeDB Version:

ArcadeDB Server v24.2.1 (build 57c5f09424ebc7c8ec19c7775f514c80129245e5/1712181097174/main)

OS and JDK Version:

Running on Mac OS X 12.7.4 - OpenJDK 64-Bit Server VM 17.0.10 (Homebrew)

Sending an async command like BACKUP DATABASE via an async HTTP command (awaitResponse: false) causes an error.

Expected behavior

Succesful database backup with async command.

Actual behavior

Async command in database "test" failed.
SEVER [PostCommandHandler$1] Async command in database "test" failed.
com.arcadedb.exception.CommandExecutionException: Error on backing up database
	at com.arcadedb.query.sql.parser.BackupDatabaseStatement.executeSimple(BackupDatabaseStatement.java:79)
	at com.arcadedb.query.sql.executor.SingleOpExecutionPlan.executeInternal(SingleOpExecutionPlan.java:91)
	at com.arcadedb.query.sql.parser.SimpleExecStatement.execute(SimpleExecStatement.java:52)
	at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:65)
	at com.arcadedb.query.sql.SQLQueryEngine.command(SQLQueryEngine.java:116)
	at com.arcadedb.database.LocalDatabase.command(LocalDatabase.java:1327)
	at com.arcadedb.database.async.DatabaseAsyncCommand.execute(DatabaseAsyncCommand.java:59)
	at com.arcadedb.database.async.DatabaseAsyncExecutorImpl$AsyncThread.run(DatabaseAsyncExecutorImpl.java:134)
Caused by: com.arcadedb.integration.backup.BackupException: Error during backup of database 'test' to file 'test-backup-20240404-112752960.zip'
	at com.arcadedb.integration.backup.Backup.backupDatabase(Backup.java:72)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at com.arcadedb.query.sql.parser.BackupDatabaseStatement.executeSimple(BackupDatabaseStatement.java:67)
	... 7 more
Caused by: com.arcadedb.integration.backup.BackupException: The backup file '/backups/test/test-backup-20240404-112752960.zip' cannot be created
	at com.arcadedb.integration.backup.format.FullBackupFormat.backupDatabase(FullBackupFormat.java:60)
	at com.arcadedb.integration.backup.Backup.backupDatabase(Backup.java:66)
	... 12 more

Steps to reproduce

Given a test database:

curl -X POST http://localhost:2480/api/v1/command/test -d '{ "language": "sql", "command": "backup database", "awaitResponse": false }' -H "Content-Type: application/json" --user root:arcadedb
@gramian
Copy link
Collaborator Author

gramian commented Apr 4, 2024

With language: sqlscript the following error is caused:

java.lang.NullPointerException: Cannot invoke "com.arcadedb.ContextConfiguration.getValueAsString(com.arcadedb.GlobalConfiguration)" because the return value of "com.arcadedb.query.sql.executor.CommandContext.getConfiguration()" is null
	at com.arcadedb.query.sql.parser.BackupDatabaseStatement.executeSimple(BackupDatabaseStatement.java:62)
	at com.arcadedb.query.sql.executor.SingleOpExecutionPlan.executeInternal(SingleOpExecutionPlan.java:91)
	at com.arcadedb.query.sql.executor.ScriptLineStep.syncPull(ScriptLineStep.java:55)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.doExecute(ScriptExecutionPlan.java:97)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.fetchNext(ScriptExecutionPlan.java:61)
	at com.arcadedb.query.sql.parser.LocalResultSet.fetchNext(LocalResultSet.java:44)
	at com.arcadedb.query.sql.parser.LocalResultSet.<init>(LocalResultSet.java:40)
	at com.arcadedb.query.sql.SQLScriptQueryEngine.executeInternal(SQLScriptQueryEngine.java:218)
	at com.arcadedb.query.sql.SQLScriptQueryEngine.command(SQLScriptQueryEngine.java:119)
	at com.arcadedb.database.LocalDatabase.command(LocalDatabase.java:1327)
	at com.arcadedb.database.async.DatabaseAsyncCommand.execute(DatabaseAsyncCommand.java:59)

@lvca lvca self-assigned this Apr 9, 2024
@lvca lvca added the bug Something isn't working label Apr 9, 2024
@lvca lvca added this to the 24.3.1 milestone Apr 9, 2024
@lvca
Copy link
Contributor

lvca commented Apr 9, 2024

I see in the async mode the server context is not passed. Fixing it.

lvca added a commit that referenced this issue Apr 9, 2024
@lvca
Copy link
Contributor

lvca commented Apr 9, 2024

Just pushed a fix. Please let me know if works.

@gramian
Copy link
Collaborator Author

gramian commented Apr 9, 2024

Hi,
unfortunately that did not fix it. Here are the new errors:

SQL

SEVER [BackupDatabaseStatement] Found pending transaction. Rolling it back before the backup...
SEVER [PostCommandHandler$1] Async command in database "test" failed.
com.arcadedb.exception.CommandExecutionException: Error on backing up database
	at com.arcadedb.query.sql.parser.BackupDatabaseStatement.executeSimple(BackupDatabaseStatement.java:79)
	at com.arcadedb.query.sql.executor.SingleOpExecutionPlan.executeInternal(SingleOpExecutionPlan.java:91)
	at com.arcadedb.query.sql.parser.SimpleExecStatement.execute(SimpleExecStatement.java:52)
	at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:65)
	at com.arcadedb.query.sql.SQLQueryEngine.command(SQLQueryEngine.java:116)
	at com.arcadedb.database.LocalDatabase.command(LocalDatabase.java:1335)
	at com.arcadedb.database.async.DatabaseAsyncCommand.execute(DatabaseAsyncCommand.java:69)
	at com.arcadedb.database.async.DatabaseAsyncExecutorImpl$AsyncThread.run(DatabaseAsyncExecutorImpl.java:136)
Caused by: com.arcadedb.integration.backup.BackupException: Error during backup of database 'test' to file 'test-backup-20240409-200107863.zip'
	at com.arcadedb.integration.backup.Backup.backupDatabase(Backup.java:72)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at com.arcadedb.query.sql.parser.BackupDatabaseStatement.executeSimple(BackupDatabaseStatement.java:67)
	... 7 more
Caused by: com.arcadedb.integration.backup.BackupException: The backup file '/backups/test/test-backup-20240409-200107863.zip' cannot be created
	at com.arcadedb.integration.backup.format.FullBackupFormat.backupDatabase(FullBackupFormat.java:60)
	at com.arcadedb.integration.backup.Backup.backupDatabase(Backup.java:66)
	... 12 more

SQLscript

SEVER [BackupDatabaseStatement] Found pending transaction. Rolling it back before the backup...
SEVER [PostCommandHandler$1] Async command in database "test" failed.
com.arcadedb.exception.CommandExecutionException: Error on backing up database
	at com.arcadedb.query.sql.parser.BackupDatabaseStatement.executeSimple(BackupDatabaseStatement.java:79)
	at com.arcadedb.query.sql.executor.SingleOpExecutionPlan.executeInternal(SingleOpExecutionPlan.java:91)
	at com.arcadedb.query.sql.executor.ScriptLineStep.syncPull(ScriptLineStep.java:55)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.doExecute(ScriptExecutionPlan.java:97)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.fetchNext(ScriptExecutionPlan.java:61)
	at com.arcadedb.query.sql.parser.LocalResultSet.fetchNext(LocalResultSet.java:44)
	at com.arcadedb.query.sql.parser.LocalResultSet.<init>(LocalResultSet.java:40)
	at com.arcadedb.query.sql.SQLScriptQueryEngine.executeInternal(SQLScriptQueryEngine.java:218)
	at com.arcadedb.query.sql.SQLScriptQueryEngine.command(SQLScriptQueryEngine.java:119)
	at com.arcadedb.database.LocalDatabase.command(LocalDatabase.java:1335)
	at com.arcadedb.database.async.DatabaseAsyncCommand.execute(DatabaseAsyncCommand.java:69)
	at com.arcadedb.database.async.DatabaseAsyncExecutorImpl$AsyncThread.run(DatabaseAsyncExecutorImpl.java:136)
Caused by: com.arcadedb.integration.backup.BackupException: Error during backup of database 'test' to file 'test-backup-20240409-200146374.zip'
	at com.arcadedb.integration.backup.Backup.backupDatabase(Backup.java:72)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at com.arcadedb.query.sql.parser.BackupDatabaseStatement.executeSimple(BackupDatabaseStatement.java:67)
	... 11 more
Caused by: com.arcadedb.integration.backup.BackupException: The backup file '/backups/test/test-backup-20240409-200146374.zip' cannot be created
	at com.arcadedb.integration.backup.format.FullBackupFormat.backupDatabase(FullBackupFormat.java:60)
	at com.arcadedb.integration.backup.Backup.backupDatabase(Backup.java:66)
	... 16 more

I also don't know where the "pending transaction" comes from. I tested on a fresh database and the first command send to it, is BACKUP DATABASE.

@lvca lvca modified the milestones: 24.4.1, 24.5.1 Apr 20, 2024
@gramian
Copy link
Collaborator Author

gramian commented Apr 25, 2024

It seems to be fixed. Great!

@gramian gramian closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants