-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(h5p-server): fix library install race conditions (#1871)
* test(h5p-server): added failing test * fix(h5p-server): fixed race condition when installing libraries * fix(h5p-server): prevent deadlocks due to library order * test(integration): throttled integration tests * test(integration): changed timeouts * ci: added ramdisk usage * fix(h5p-server): increased default library install lock timeouts * ci: ramdisk fix * ci: fixed typo * ci: increased timeout times * ci: try to fix timeouts * ci: fix jest call * ci: even more extreme timeouts * feat: added Redis lock provider * test(h5p-redis-lock): added test for redis lock * test(h5p-redis-lock): improved tests * test(h5p-redis-lock): use mocks for redis tests * docs(h5p-redis-lock): added docs
- Loading branch information
Showing
39 changed files
with
33,501 additions
and
31,712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# h5p-redis-lock | ||
|
||
This package provides a lock mechanism that can be used if the library runs in | ||
multi-process or cluster-mode. The locks are needed to avoid race conditions | ||
when installing libraries. | ||
|
||
```ts | ||
import ioredis from 'ioredis-mock'; | ||
import { H5PEditor, H5PPlayer } from '@lumieducation/h5p-server'; | ||
import RedisLockProvider from '@lumieducation/h5p-redis-lock'; | ||
|
||
// Create a regular ioredis connection | ||
const redis = new ioredis(redisPort, redisHost, { db: redisDb }); | ||
|
||
// Create the lock provider | ||
const lockProvider = new RedisLockProvider(redis); | ||
|
||
// Pass it to the editor and player object | ||
const h5pEditor = new H5PEditor( /*other parameters*/, options: { lockProvider } ); | ||
const h5pPlayer = new H5PPlayer( /*other parameters*/, options: { lockProvider } ); | ||
``` | ||
|
||
It is important to make sure that all instances of H5PEditor use a redis lock | ||
provider that points to the same database. Otherwise race conditions can happen. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.