evazion 48ecb80d6b Fix #5230: video upload 500 error (StatementInvalid) & empty error panel on page
Fix StatementInvalid exception when uploading https://files.catbox.moe/vxoe2p.mp4.

This was a result of multiple bugs:

* First, generating thumbnails for the video failed. This was because
  the video uses the AV1 codec, which FFmpeg failed to decode. It failed
  because our version of FFmpeg was built without the `--enable-libdav1d`
  flag, so it uses the builtin AV1 decoder, which apparently can't
  handle this particular video (it spews a bunch of errors about "Failed
  to get pixel format" and "missing sequence header" and "failed to get
  reference frame").

* Because generating the thumbnails failed, an exception was raised. We
  tried to save the error message in the upload_media_assets.error
  field. However, this also failed because the error message was 77kb
  long (it contained the entire output of the ffmpeg command), but the
  `upload_media_assets` table had a btree index on the `error` column,
  which meant the maximum length of the error column was limited to
  ~2.7kb. This lead to a StatementInvalid exception being raised.

* Because the StatementInvalid exception was raised while we were trying
  to set the upload media asset's status to `failed`, the upload was
  left stuck in the `processing` state rather than being set to the
  `failed` state.

* Because the upload was stuck in the `processing` state, the upload
  page would hang forever waiting for the upload to complete.

The fixes are to:

* Build FFmpeg with `--enable-libdav1d` to use libdav1d for decoding AV1
  videos instead of the builtin AV1 decoder.

* Remove the index on the `upload_media_assets.error` column so that
  setting overly long error messages won't fail.

* Catch unexpected exceptions in ProcessUploadMediaAssetJob so we can
  mark uploads as failed, even if `process_upload!` itself fails because
  it raises an unexpected exception inside its own exception handler.

* Check that the video is playable with `MediaFile::Video#is_corrupt?` before
  allowing it to be uploaded. This way we can return a better error
  message if we can't generate thumbnails because the video isn't
  playable. This requires decoding the entire video, so it means uploads
  may take several seconds longer for long videos. It's also a security
  risk in case ffmpeg has any bugs.

* Define `MediaAsset#preview!` as raising an exception on error, so
  it's clear that generating thumbnails can fail. Define `MediaAsset#preview`
  as returning nil on error for when we don't care about the cause of
  the error.
2022-10-26 22:49:55 -05:00
2019-10-28 21:37:34 -05:00
2021-03-01 00:39:47 -06:00
2022-04-23 21:16:37 -05:00
2022-10-18 20:13:43 -05:00
2022-03-15 14:06:16 +01:00
2022-04-09 14:54:15 +02:00
2022-10-26 04:15:37 -05:00
2021-09-14 21:40:39 -05:00
2022-04-21 21:43:06 -05:00
2020-06-27 13:03:04 -05:00
2021-06-17 04:10:26 -05:00
2022-01-17 11:58:19 -06:00
2021-03-01 00:39:47 -06:00
2021-03-31 21:32:01 -05:00
2021-09-20 06:17:57 -05:00
2020-06-07 17:14:41 -05:00
2022-10-26 04:15:37 -05:00
2022-04-21 21:43:06 -05:00
2021-01-28 16:20:56 +09:00
2022-03-06 23:28:53 -06:00
2019-12-22 21:23:37 -06:00
2021-09-24 08:40:33 -05:00

codecov Discord

Quickstart

Run this to start a basic Danbooru instance:

curl -sSL https://raw.githubusercontent.com/danbooru/danbooru/master/bin/danbooru | sh

This will install Docker Compose and use it to start Danbooru. When it's done, Danbooru will be running at http://localhost:3000.

Alternatively, if you already have Docker Compose installed, you can just do:

wget https://raw.githubusercontent.com/danbooru/danbooru/master/docker-compose.yaml
docker-compose up

Manual Installation

Follow the INSTALL.debian script to install Danbooru.

The INSTALL.debian script is written for Debian, but can be adapted for other distributions. Danbooru has been successfully installed on Debian, Ubuntu, Fedora, Arch, and OS X. It is recommended that you use an Ubuntu-based system since Ubuntu is what is used in development and production.

See here for a guide on how set up Danbooru inside a virtual machine.

For best performance, you will need at least 256MB of RAM for PostgreSQL and Rails. The memory requirement will grow as your database gets bigger.

In production, Danbooru uses PostgreSQL 10.18, but any release later than this should work.

Troubleshooting

If your setup is not working, here are the steps I usually recommend to people:

  1. Test the database. Make sure you can connect to it using psql. Make sure the tables exist. If this fails, you need to work on correctly installing PostgreSQL, importing the initial schema, and running the migrations.

  2. Test the Rails database connection by using bin/rails console. Run Post.count to make sure Rails can connect to the database. If this fails, you need to make sure your Danbooru configuration files are correct.

  3. Test Nginx to make sure it's working correctly. You may need to debug your Nginx configuration file.

  4. Check all log files.

Services

Danboou depends on a couple of cloud services and several microservices to implement certain features.

Amazon Web Services

The following features require an Amazon AWS account:

  • Pool history
  • Post history

Google APIs

The following features require a Google Cloud account:

  • BigQuery database export

IQDB Service

IQDB integration is delegated to the IQDB service.

Archive Service

In order to access pool and post histories you will need to install and configure the Archives service.

Reportbooru Service

The following features are delegated to the Reportbooru service:

  • Post views
  • Missed searches report
  • Popular searches report

Recommender Service

Post recommendations require the Recommender service.

Description
No description provided
Readme 68 MiB
Languages
Ruby 78.3%
HTML 13.5%
JavaScript 3.5%
SCSS 2.5%
Nix 1.6%
Other 0.5%