8000 appwrite maria db database is mysteriously deleted · Issue #6333 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

appwrite maria db database is mysteriously deleted #6333

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

Closed
2 tasks done
Edijae opened this issue Sep 26, 2023 · 8 comments
Closed
2 tasks done

appwrite maria db database is mysteriously deleted #6333

Edijae opened this issue Sep 26, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@Edijae
Copy link
Edijae commented Sep 26, 2023

👟 Reproduction steps

I created database and tables using appwrite console and was able to store data in them using the server API and it reflects on the console. today i tried to make an api call to get the data but i got a 500 error.

let client  =   new appwrite.Client()
        .setEndpoint(serverEndpoint)
        .setProject(serverProject)
        .setSelfSigned(true)
        .setKey(serverKey);

let db = new appwrite.Databases(client);

let userId = req.query.userId as string
   
    try {
        let query = [Query.equal("userId", userId)]
        let response = await db.listDocuments<Item>(dbId, collectionId, query);
    } catch (error) {
        console.log(error);
    }

Error

code: 500,
  type: 'general_unknown',
  response: {
    message: 'Server Error',
    code: 500,
    type: 'general_unknown',
    version: '1.4.3',
    file: '@swoole-src/library/core/Database/PDOStatementProxy.php',
    line: 62,
    trace: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object]
    ]
  }
}

checking. appwrite docker container logs i see the error below

[Error] Method: GET
[Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents
[Error] Type: PDOException
[Error] Message: Table 'appwrite._console_keys' doesn't exist
[Error] File: @swoole-src/library/core/Database/PDOStatementProxy.php
[Error] Line: 62
[Error] Timestamp: 2023-09-26T11:24:32+00:00

i accessed maria db container using the docker exec -it mariadb bash command and saw there were no tables in the appwrite db.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| appwrite           |
| information_schema |
+--------------------+
MariaDB [(none)]> use appwrite;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [appwrite]> show tables;
+--------------------+
| Tables_in_appwrite |
+--------------------+
| README             |
+--------------------+
1 row in set (0.000 sec)


What could be the issue? i never deleted anything. this is a big concern if data can disappear or be deleted automatically

👍 Expected behavior

Data. should not disappear/be deleted automatically

👎 Actual Behavior

Database is been deleted

🎲 Appwrite version

Version 1.4.x

💻 Operating system

Linux

🧱 Your Environment

v 1.4.3

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@Edijae Edijae added the bug Something isn't working label Sep 26, 2023
@stnguyen90 stnguyen90 self-assigned this Sep 26, 2023
@stnguyen90
Copy link
Contributor

@Edijae, thanks for raising this issue! 🙏🏼 Some questions for you:

  1. Did you stop anything since yesterday?
  2. Is there anything in docker logs for some of the other containers like:
    1. appwrite-worker-databases
    2. appwrite-worker-deletes
    3. mariadb

@Edijae
Copy link
Author
Edijae commented Sep 26, 2023

@stnguyen90 I did not stop anything since yesterday. when i checked appwrite-worker-databases, i didn't. see any suspicious logs but when i checked appwrite-worker-deletes using docker logs -f appwrite-worker-deletes i saw some suspicious logs

[notice] Starting work on (Job{v1-deletes} | ID: 5003c7b9b8f2ea9615ecf8c1239c8d1c | DeletesV1 | [{"project":{"teamInternalId":"1","teamId":"6508abcdcee98f3d249c","name":"AppDb","region":"default","description":"","database":"database_db_main","logo":"","url":"","version":"1.4.3","legalName":"","legalCountry":"","legalState":"","legalCity":"","legalAddress":"","legalTaxId":"","services":[],"smtp":[],"templates":[],"auths":{"limit":0,"maxSessions":10,"passwordHistory":0,"passwordDictionary":false,"duration":31536000,"personalDataCheck":false,"emailPassword":true,"usersAuthMagicURL":true,"anonymous":true,"invites":true,"JWT":true,"phone":true},"authProviders":[],"platforms":[],"webhooks":[],"keys":[{"projectInternalId":"1",)","update(\"team:6508abcdcee98f3d249c\/owner\")","update(\"team:6508abcdcee98f3d249c\/developer\")","delete(\"team:6508abcdcee98f3d249c\/owner\")","delete(\"team:6508abcdcee98f3d249c\/developer\")"],"$collection":"projects"},"type":"cacheByResource","document":null,"resource":"file\/651134f82c7fb28f97f5","datetime":null,"hourlyUsageRetentionDatetime":null}]

@Edijae
Copy link
Author
Edijae commented Sep 26, 2023

@stnguyen90 then there is this latest log

[notice] Starting work on (Job{v1-deletes} | ID: 44dda0f105c6fd870eb0613577e46c5e | DeletesV1 | [{"project":null,"type":"sessions","document":null,"resource":null,"datetime":null,"hourlyUsageRetentionDatetime":null}])
[critical] (Job{v1-deletes} | ID: 44dda0f105c6fd870eb0613577e46c5e | DeletesV1 | [{"project":null,"type":"sessions","document":null,"resource":null,"datetime":null,"hourlyUsageRetentionDatetime":null}]) has failed PDOException: Table 'appwrite._console__metadata' doesn't exist in @swoole-src/library/core/Database/PDOStatementProxy.php:62
Stack trace:
#0 /usr/src/code/vendor/utopia-php/database/src/Database/Adapter/SQL.php(122): Swoole\Database\PDOStatementProxy->__call('execute', Array)
#1 /usr/src/code/vendor/utopia-php/database/src/Database/Database.php(2265): Utopia\Database\Adapter\SQL->getDocument('_metadata', 'projects', Array)
#2 /usr/src/code/vendor/utopia-php/database/src/Database/Database.php(776): Utopia\Database\Database->getDocument(Object(Utopia\Database\Document), 'projects')
#3 /usr/src/code/vendor/utopia-php/database/src/Database/Database.php(430): Utopia\Database\Database->Utopia\Database\{closure}()
#4 /usr/src/code/vendor/utopia-php/database/src/Database/Database.php(776): Utopia\Database\Database->silent(Object(Closure))
#5 /usr/src/code/vendor/utopia-php/database/src/Database/Database.php(4058): Utopia\Database\Database->getCollection('projects')
#6 /usr/src/code/vendor/utopia-php/database/src/Database/Database.php(430): Utopia\Database\Database->Utopia\Database\{closure}()
#7 /usr/src/code/vendor/utopia-php/database/src/Database/Database.php(4058): Utopia\Database\Database->silent(Object(Closure))
#8 /usr/src/code/app/workers/deletes.php(754): Utopia\Database\Database->find('projects', Array)
#9 /usr/src/code/app/workers/deletes.php(512): DeletesV1->deleteForProjectIds(Object(Closure))
#10 /usr/src/code/app/workers/deletes.php(113): DeletesV1->deleteExpiredSessions()
#11 /usr/src/code/src/Appwrite/Resque/Worker.php(125): DeletesV1->run()
#12 /usr/src/code/vendor/resque/php-resque/lib/Resque/Job.php(201): Appwrite\Resque\Worker->perform()
#13 /usr/src/code/vendor/resque/php-resque/lib/Resque/Worker.php(303): Resque_Job->perform()
#14 /usr/src/code/vendor/resque/php-resque/lib/Resque/Worker.php(242): Resque_Worker->perform(Object(Resque_Job))
#15 /usr/src/code/vendor/resque/php-resque/bin/resque(185): Resque_Worker->work('1', false)
#16 {main}

@Edijae
8000
Copy link
Author
Edijae commented Sep 26, 2023

@stnguyen90 I see like there is no documentation about all the services in docker compose file. I'm now wondering what triggers the delete function in the logs above. also how can i recover the database? i've lost alot of tables and it will take. time to recreate them?

Also what will happen if this service is removed in the docker compose file?

@stnguyen90
Copy link
Contributor

@Edijae, the log in the appwrite-worker-deletes container is for deleting a cached file so that shouldn't have done anything to your database.

PDOException: Table 'appwrite._console__metadata' doesn't exist

This is probably because the data doesn't exist anymore.

I see like there is no documentation about all the services in docker compose file

We have some documentation here.

how can i recover the database?

The only way to recover is if you had a backup of the data before.

Also what will happen if this service is removed in the docker compose file?

If a service is removed and you run docker compose up -d the stack will be recreated/restarted and the removed service will be orphaned. Your data should still remain intact, though because volumes persist data.

I'm not sure what happened to your data or how the tables were deleted and this is the first time I've heard of this being reported.

@Edijae
Copy link
Author
Edijae commented Sep 27, 2023

@stnguyen90 I'm seeing some suspicious logs from maria db container

'@'80.66.76.58' (using password: YES)access denied for user 'bankruptcy

'@'80.66.76.58' (using password: YES)ccess denied for user 'Admin
'@'80.66.76.58' (using password: YES)ccess denied for user 'Admin
2023-09-26 23:10:13 14231 [Warning] Aborted connection 14231 to db: 'unconnected' user: 'unauthenticated' host: '167.94.145.59' (This connection closed normally without authentication)
'@'80.66.76.58' (using password: YES)ccess denied for user 'ADMIN

Access denied for user 'root'@'80.66.76.58' (using password: YES)
2023-09-27 11:35:29 20170 [Warning] Aborted connection 20170 to db: 'unconnected' user: 'unauthenticated' host: '184.105.247.231' (This connection closed normally without authentication)

'@'80.66.76.58' (using password: YES)ccess denied for user 'manager
'@'80.66.76.58' (using password: YES)ccess denied for user 'Manager
'@'80.66.76.58' (using password: YES)ccess denied for user 'MANAGER

2023-09-27 11:35:34 20173 [Warning] Access denied for user 'root'@'80.66.76.58' (using password: YES)
Access denied for user 'admin'@'80.66.76.58' (using password: YES)

i tried to look up the ip address and this is what i got https://ipinfo.io/80.66.76.58

user bankruptcy,manager,MANAGER,COLLECTOR,root,root'@'80.66.76.58. i don't have any user with that kind of names.

Is this an attack?

@Edijae
Copy link
Author
Edijae commented Sep 27, 2023

@stnguyen90 I found i had exposed the mariadb container to host using ports command and i was using default appwrite db credentials. probably someone accessed and cleared the db. luckily it was just a test environment. I've removed the ports command and changed db credentials. how can one automatically maintain a copy of the db? or do a backup of the db?

@stnguyen90
Copy link
Contributor

@Edijae dang that's scary 👀

how can one automatically maintain a copy of the db? or do a backup of the db?

See https://youtu.be/lM5yZEPtlvg?si=YtL5ig3BxZHI9qv0

@stnguyen90 stnguyen90 closed this as not planned Won't fix, can't repro, duplicate, stale 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
0