Commit Graph

1918 Commits

Author SHA1 Message Date
Artem Konev
f2d9633566 Updated phrasing and corrected errors in docs/changes.xml. 2021-02-04 14:34:42 +00:00
Max Romanov
75a5dcfc4e Fixing shared app queue unmap size.
Shared app queue takes more memory than port memory.  To unmap all memory pages
correct size need to be specified for munmap() call.  Otherwise 4 Mb memory
leaked on each configured application removal.

The issue was introduced in 1d84b9e4b459.
2021-02-03 23:23:28 +03:00
Max Romanov
b1685dbc76 Fixing possible NULL dereference.
For listen socket request reply port can be NULL if Router crashes immediately
after issuing the request.

Found by Coverity (CID 366310).
2021-02-03 23:23:17 +03:00
Max Romanov
8c88537e6e Using shared memory to pass configuration to main process.
This patch is required to remove fragmented messages functionality.
2021-02-03 23:23:06 +03:00
Konstantin Pavlov
d4d704bc7f Docker: reverted 44154b830401.
Automatic synchronisation is now set up, so manual pushes to AWS ECR are
discouraged.
2021-02-02 16:46:10 +03:00
Valentin Bartenev
93ac087e96 Fixed building by GCC 10 with -flto and -O2.
This closes #467 issue on GitHub.
2021-02-01 18:55:49 +03:00
Konstantin Pavlov
510bdf15be Regenerated Dockerfiles. 2021-02-01 18:05:12 +03:00
Konstantin Pavlov
df8ac184fd Docker: based docker images off official languages ones.
Language versions are bumped to:
 - python 3.9
 - ruby 2.7
 - go 1.15
 - node 15
 - perl 5.32

Removed images:
 - python 2.7 due to EOL
 - full/latest due to incompatibility with the new scheme
2021-01-13 22:33:14 +03:00
Valentin Bartenev
0ddbc00d7d Fixed changelog style. 2021-01-28 19:22:17 +03:00
Max Romanov
46a8c98a1a Removing unused mutex from nxt_process_t. 2021-01-28 18:32:12 +03:00
Max Romanov
e4e444b827 Router: fixing crash after WebSocket processing.
After WebSocket processing, the application port was released with incorrect
reason ("got request"), unnecessarily decrementing the active request counter.

The assertion was triggered only on application removal; a test was added
for this case.
2021-01-28 17:13:52 +03:00
Max Romanov
3855f1c032 Router: fixing error handling in config request.
The controller process awaits the response from the router for every
configration change request.  This patch adds error reporting for various error
conditions which may happen because of file descriptors or memory shortage.

Lack of a response lead to the controller awaiting the response, thus being
unable to process other client reconfiguration requests that also became stuck.
2021-01-27 17:32:03 +03:00
Andrei Belov
e4f7d1a29c Packages: added Fedora 33 support. 2021-01-26 13:06:30 +03:00
Max Romanov
9b76505bf7 Router: fixing assertion in shortage of file descriptors.
Each application in router process required fd for a request queue shared
memory.  When the number of file descripts close to the limit, and port sockets
successfully opened, router needs to properly handle the errors.

This patch closes port sockets before destroying port structure to avoid
file descriptors leakage and assertion in debug build.
2021-01-25 13:13:17 +03:00
Valentin Bartenev
6e28263d65 Bumping year in copyright notice. 2021-01-18 16:48:47 +03:00
Andrei Zeliankou
d43a84139d Tests: added missing checks for configuration results. 2021-01-14 03:04:20 +00:00
Andrei Zeliankou
5d983ea762 Tests: added test for "procfs" option. 2021-01-13 06:24:41 +00:00
Andrei Zeliankou
22dac5bd62 Tests: "language_deps" option checked more carefully. 2021-01-13 06:24:32 +00:00
Andrei Zeliankou
db9b70932b Tests: waitformount() and waitforunmount() introduced. 2021-01-13 06:24:26 +00:00
Andrei Zeliankou
6dc9c47ccd Tests: style. 2021-01-13 06:22:43 +00:00
Andrei Zeliankou
f5ac143246 Tests: unit_stop() removed where possible.
Since wait_for_record() was introduced there is no need
to stop Unit before parsing unit.log.
2021-01-12 06:20:23 +00:00
Tiago Natel de Moura
a0bc946db3 Tests: fixed test_respawn.py to act upon test processes.
Running `test_respawn_` test cases on a machine with Unit
daemon in background would fail tests because `ps ax` was
used without filtering out other unit instances.

This patch also prevents from tests killing other Unit
processes not related to tests.
2021-01-08 10:38:46 +00:00
Tiago Natel de Moura
13a06497de Tests: reordered asserts to avoid a test race.
The mount points are unmounted in the main process after it
detects the app process died.  By testing the `tmpfs: true`
first, it happens that main could start the `tmpfs: false`
test case before main cleans the old process mount points.
2021-01-07 16:51:27 +00:00
Max Romanov
d65a66f9d8 Libunit: processing single port message.
This partially reverts the optimisation introduced in 1d84b9e4b459 to avoid an
unpredictable block in nxt_unit_process_port_msg().  Under high load, this
function may never return control to its caller, and the external event loop
(in Node.js and Python asyncio) won't be able to process other scheduled
events.

To reproduce the issue, two request processing types are needed: 'fast' and
'furious'.  The 'fast' one simply returns a small response, while the 'furious'
schedules asynchronous calls to external resources.  Thus, if Unit is subjected
to a large amount of 'fast' requests, the 'furious' request processing freezes
until the high load ends.

The issue was found by Wu Jian Ping (@wujjpp) during Node.js stream
implementation discussion and relates to PR #502 on GitHub.
2020-12-29 19:01:24 +03:00
Max Romanov
d3d6864bdc Node.js: ServerRequest and ServerResponse compliance to Stream API.
ServerRequest now inherit stream Readable object.  ServerResponse
provides 'writable' property.

Thanks to Wu Jian Ping (@wujjpp).

This closes #274, closes #317 issues and closes #502 PR on GitHub.
2020-12-29 19:00:54 +03:00
Andrei Belov
3abca42caf Packages: fixed building for Ubuntu 16.04 "xenial".
Changes introduced in a27532e3a17b effectively broke building of the unit
package due to missed dh_installsystemd script in older debhelper 9.x.

Once Ubuntu 16.04 reach EOL, the following actions should be made:
 - this commit should be reverted;
 - minimal debhelper version should be increased to 11.
2020-12-28 12:51:30 +03:00
Andrei Belov
c981ac6558 Packages: fixed an ability to override package version.
This was broken since 00d8049418cf.
2020-12-24 16:17:27 +03:00
Andrei Belov
c369e25ae7 Version bump for unit modules.
This is required in order to build Debian packages from current tip
without making manual interventions.

Moving forward, this should be a part of every version bump commit.
2020-12-24 15:18:49 +03:00
Andrei Belov
c99b175988 Packages: set the "--user" value to "nobody" for build-stage tests.
This allows tests to pass well in cases when the default user specified in
the ./configure parameters does not exist in the building environment.
2020-12-23 18:31:18 +03:00
Andrei Belov
53af12def0 Tests: ability to run unitd with specified "--user" option. 2020-12-23 18:30:17 +03:00
Max Romanov
b7dba90062 Static: fixing request memory pool leakage in router.
When a static file larger than NXT_HTTP_STATIC_BUF_SIZE (128K) is served, two
buffers are allocated and chained; each retains the whole request memory pool.

Starting from 41331471eee7, the completion handler was called once for a linked
buffer chain, but the second buffer got lost.

This patch improves the completion handler's treatment of static buffers to
handle all linked buffers.
2020-12-23 11:01:36 +03:00
Valentin Bartenev
cac762ab7e Python: multiple values in the "path" option. 2020-12-22 17:53:41 +03:00
Konstantin Pavlov
65295c8141 Packages: check and create unit user on each post-script invocation. 2020-12-22 12:57:24 +03:00
Tiago Natel de Moura
03436d2ec2 Tests: introduced a separate cache directory for Go builds.
The Go compiler can't detect changes to C header files when
compiling CGO applications, and then this leads to Go test
samples being linked with wrong libunit.

This patch creates a new cache directory reused throughout
the test suite.
2020-12-21 11:00:46 +00:00
Max Romanov
7b669ed866 Libunit: fixed shared memory waiting.
The nxt_unit_ctx_port_recv() function may return the NXT_UNIT_AGAIN code, in
which case an attempt to reread the message should be made.

The issue was reproduced in load testing with response sizes 16k and up.
In the rare case of a NXT_UNIT_AGAIN result, a buffer of size -1 was processed,
which triggered a 'message too small' alert; after that, the app process was
terminated.
2020-12-18 00:25:28 +03:00
Max Romanov
7389a50835 Limiting app queue notifications count in socket.
Under high load, a queue synchonization issue may occur, starting from the
steady state when an app queue message is dequeued immediately after it has been
enqueued.  In this state, the router always puts the first message in the queue
and is forced to notify the app about a new message in an empty queue using a
socket pair.  On the other hand, the application dequeues and processes the
message without reading the notification from the socket, so the socket buffer
overflows with notifications.

The issue was reproduced during Unit load tests.  After a socket buffer
overflow, the router is unable to notify the app about a new first message.
When another message is enqueued, a notification is not required, so the queue
grows without being read by the app.  As a result, request processing stops.

This patch changes the notification algorithm by counting the notifications in
the pipe instead of getting the number of messages in the queue.
2020-12-18 00:25:27 +03:00
Max Romanov
c0449e13f8 Router: fixed crash in OOSM processing.
Multithreaded application may create different shared memory segments in
different threads.  The segments then passed to different router threads.
Because of this multithreading, the order of adding incoming segments is
not determined and there can be situation when some of the incoming segments
are not initialized yet.

This patch simply adds check for NULL to skip non-initialized segments.

Crash reproduced during load tests with high number of simultaneous
connections (1024 and more).
2020-12-17 19:27:44 +03:00
Andrei Belov
53d847615b Packages: run non-privileged processes under "unit" user. 2020-12-17 14:30:18 +03:00
Konstantin Pavlov
a5fa9673d9 Packages: added pcre2 to build depends.
While at it, propagate unit build depends to modules.
2020-11-24 14:27:06 +03:00
Konstantin Pavlov
9c09bc1772 Packages: dropped support for non-systemd distributions. 2020-11-24 13:25:09 +03:00
Andrei Belov
c33b10a41f Packages: eliminated debuild warning about debian/rules. 2020-12-16 09:56:04 +03:00
Andrei Belov
0c1abda391 Packages: the NOTICE file added to debian binaries.
This resolves the following lintian error:
https://lintian.debian.org/tags/missing-notice-file-for-apache-license.html

While here, changed upstream changelog name to conform with the policy:
https://lintian.debian.org/tags/wrong-name-for-upstream-changelog.html
2020-12-16 09:56:01 +03:00
Andrei Belov
d15acabfc5 Packages: introduced PYTEST_ARGS env variable for test targets.
This is useful for running particular tests, e.g.:
PYTEST_ARGS='test/test_respawn.py::TestRespawn::test_respawn_router' make test
2020-12-16 09:55:59 +03:00
Tiago Natel de Moura
ea5844ae7b Added a changelog for 5e6c2b8fb3fe. 2020-12-15 13:01:44 +00:00
Tiago Natel de Moura
66ac35e9b9 Tests: fixed bug that disabled isolation tests. 2020-12-15 11:06:49 +00:00
Valentin Bartenev
8d65a3303b Python: WSGI environment copying moved out of request processing.
The WSGI environment dictionary contains a number of static items, that are
pre-initialized on application start.  Then it's copied for each request to be
filled with request-related data.

Now this dictionary copy operation will be done between processing of requests,
which should save some CPU cycles during request processing and thus reduce
response latency for non-peak load periods.
2020-12-14 17:15:49 +03:00
Tiago Natel de Moura
1e9def50c8 Isolation: fixed unmounting when mnt namespace is in place.
The code had a wrong assumption that "mount namespaces" automatically
unmounts process mounts when exits but this happens only with
unprivileged mounts.
2020-12-14 12:00:28 +00:00
Andrei Zeliankou
425ffc9416 Tests: hyphen sign used unstead of underscore as more common. 2020-12-12 20:08:03 +00:00
Andrei Zeliankou
16ac829c8f Tests: added tests for PHP_AUTH_* variables. 2020-12-10 19:28:41 +00:00
Andrei Zeliankou
7be62c3c21 Tests: TestUnit class removed.
Prerequisite checks moved to the fixture in conftest.py.
2020-12-09 16:17:46 +00:00