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

fix: disallow multiple build commands #6360

Merged
merged 1 commit into from
Nov 8, 2022

Conversation

rgrinberg
Copy link
Member

@rgrinberg rgrinberg commented Oct 30, 2022

Okay this improves on #6244 by providing some lock file functionality. @Alizter do you mind giving this some thorough testing?

@rgrinberg rgrinberg requested a review from Alizter October 30, 2022 01:59
@rgrinberg rgrinberg changed the title fix: disallow multiple rpc servers fix: disallow multiple rpc servers and build commands Oct 30, 2022
@rgrinberg rgrinberg linked an issue Oct 30, 2022 that may be closed by this pull request
@rgrinberg rgrinberg added this to the 3.6.0 milestone Oct 30, 2022
@rgrinberg rgrinberg force-pushed the ps/rr/fix__disallow_multiple_rpc_servers branch from aa4fa9d to 30de814 Compare October 30, 2022 02:03
@rgrinberg rgrinberg changed the title fix: disallow multiple rpc servers and build commands fix: disallow multiple build commands Oct 30, 2022
Copy link
Collaborator

@Alizter Alizter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I've tested doing simultaneous dune buildss both with and without watch mode and I am getting the correct error message

Error: Dune already running in this build directory. If this is not the case,
delete _build/.rpc/dune

Now there is a good reason to actually want to do a simultaneous build, say you are running dune build @check -w and it is waiting, but you want to build some other target. At the moment you will have to stop the build in watch mode to do this, or modify it.

I suppose there is room for improvement here where other Dune build calls can send build requests to the currently running RPC server. But I guess that can come in a later PR.

src/dune_rpc_impl/server.ml Outdated Show resolved Hide resolved
src/dune_rpc_impl/server.ml Outdated Show resolved Hide resolved
@Alizter
Copy link
Collaborator

Alizter commented Oct 30, 2022

Also this does not fix #5449. I imagine making dune clean observe the lock file wouldn't be too difficult to do.

@rgrinberg rgrinberg force-pushed the ps/rr/fix__disallow_multiple_rpc_servers branch 6 times, most recently from cf597a3 to 205a082 Compare October 31, 2022 13:49
@rgrinberg rgrinberg requested a review from gridbugs October 31, 2022 15:37
@rgrinberg
Copy link
Member Author

@gridbugs I've added you as a reviewer as well. It will be good to familiarize with other parts of the codebase. It's a fairly large PR, so there's plenty to review for both you and Ali.

A good background reading is:

@Alizter

This comment was marked as resolved.

@rgrinberg rgrinberg force-pushed the ps/rr/fix__disallow_multiple_rpc_servers branch 3 times, most recently from 9815f43 to 7919af4 Compare November 1, 2022 01:26
@Alizter
Copy link
Collaborator

Alizter commented Nov 1, 2022

I wasn't able to reproduce the issue from before, so it is was probably my mistake.

I've tested the new version both in watch mode and without and there are no issues and the error message is displayed correctly. Builds in different workspaces can continue together also.

Copy link
Collaborator

@Alizter Alizter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with everything apart from the flock C code, since I don't understand it just yet.

I see that #5449 is now fixed!

@rgrinberg rgrinberg force-pushed the ps/rr/fix__disallow_multiple_rpc_servers branch 7 times, most recently from cbbb9e2 to 0b71972 Compare November 1, 2022 20:58
@rgrinberg rgrinberg force-pushed the ps/rr/fix__disallow_multiple_rpc_servers branch 2 times, most recently from efd816a to b5d4221 Compare November 2, 2022 01:44
@rgrinberg rgrinberg force-pushed the ps/rr/fix__disallow_multiple_rpc_servers branch from b5d4221 to 18e69a9 Compare November 2, 2022 14:28
@rgrinberg
Copy link
Member Author

ping @gridbugs

@Alizter I've updated a few more things. Worth another look.

@rgrinberg rgrinberg force-pushed the ps/rr/fix__disallow_multiple_rpc_servers branch 2 times, most recently from 93a7a0b to 64090d5 Compare November 3, 2022 17:36
Running dune concurrently is no longer allowed because we create the rpc
socket file eagerly and treat it as a lock

Signed-off-by: Rudi Grinberg <[email protected]>

ps-id: 491f09b0-a316-43b8-8df5-a05f53fa331a
@rgrinberg rgrinberg force-pushed the ps/rr/fix__disallow_multiple_rpc_servers branch from 64090d5 to 9f97019 Compare November 4, 2022 21:09
@rgrinberg
Copy link
Member Author

Will merge this tomorrow unless anyone objects.

@rgrinberg rgrinberg merged commit 833e99a into main Nov 8, 2022
@emillon
Copy link
Collaborator

emillon commented Nov 8, 2022

Should this get a changelog entry?

@Blaisorblade
Copy link
Contributor

@emillon 👍 I was about to ask the same — since this is a user-visible behavior change IIUC?

@rgrinberg
Copy link
Member Author

rgrinberg commented Nov 10, 2022 via email

@Alizter Alizter deleted the ps/rr/fix__disallow_multiple_rpc_servers branch November 12, 2022 15:15
emillon added a commit to emillon/opam-repository that referenced this pull request Nov 14, 2022
…ne-site, dune-rpc, dune-rpc-lwt, dune-private-libs, dune-glob, dune-configurator, dune-build-info, dune-action-plugin and chrome-trace (3.6.0)

CHANGES:

- Forbid multiple instances of dune running concurrently in the same workspace.
  (ocaml/dune#6360, fixes ocaml/dune#236, @rgrinberg)

- Allow promoting into source directories specified by `subdir` (ocaml/dune#6404, fixes
  ocaml/dune#3502, @rgrinberg)

- Make dune describe workspace return the correct root path
  (ocaml/dune#6380, fixes ocaml/dune#6379, @esope)

- Introduce a `$ dune ocaml top-module` subcommand to load modules directly
  without sealing them behind the signature. (ocaml/dune#5940, @rgrinberg)

- [ctypes] do not mangle user written names in the ctypes stanza (ocaml/dune#6374, fixes
  ocaml/dune#5561, @rgrinberg)

- Support `CLICOLOR` and `CLICOLOR_FORCE` to enable/disable/force ANSI
  colors. (ocaml/dune#6340, fixes ocaml/dune#6323, @MisterDA).

- Forbid private libraries with `(package ..)` set from depending on private
  libraries that don't belong to a package (ocaml/dune#6385, fixes ocaml/dune#6153, @rgrinberg)

- Allow `Byte_complete` binaries to be installable (ocaml/dune#4873, @AltGr, @rgrinberg)

- Revive `$ dune external-lib-deps` under `$ dune describe external-lib-deps`.
  (ocaml/dune#6045, @moyodiallo)

- Fix running inline tests in bytecode mode (ocaml/dune#5622, fixes ocaml/dune#5515, @dariusf)

- [ctypes] always re-run `pkg-config` because we aren't tracking its external
  dependencies (ocaml/dune#6052, @rgrinberg)

- [ctypes] remove dependency on configurator in the generated rules (ocaml/dune#6052,
  @rgrinberg)

- Build progress status now shows number of failed jobs (ocaml/dune#6242, @Alizter)

- Allow absolute build directories to find public executables. For example,
  those specified with `(deps %{bin:...})` (ocaml/dune#6326, @anmonteiro)

- Create a fake socket file `_build/.rpc/dune` on windows to allow rpc clients
  to connect using the build directory. (ocaml/dune#6329, @rgrinberg)

- Prevent crash if absolute paths are used in the install stanza and in
  recursive globs. These cases now result in a user error. (ocaml/dune#6331, @gridbugs)

- Add `(glob_files <glob>)` and `(glob_files_rec <glob>)` terms to the `files`
  field of the `install` stanza (ocaml/dune#6250, closes ocaml/dune#6018, @gridbugs)

- Allow `:standard` in the `(modules)` field of the `coq.pp` stanza (ocaml/dune#6229,
  fixes ocaml/dune#2414, @Alizter)

- Fix passing of flags to dune coq top (ocaml/dune#6369, fixes ocaml/dune#6366, @Alizter)

- Extend the promotion CLI to a `dune promotion` group: `dune promote` is moved
  to `dune promotion apply` (the former still works) and the new `dune promotion
  diff` command can be used to just display the promotion without applying it.
  (ocaml/dune#6160, fixes ocaml/dune#5368, @emillon)
@nojb nojb mentioned this pull request Nov 19, 2022

CAMLprim value dune_flock_lock(value v_fd, value v_block, value v_exclusive) {
#ifdef _WIN32
caml_failwith("no flock on win32");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's LockFileEx on Windows https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-lockfileex which seems pretty similar to flock. Perhaps it can be used to implement this C stub on Windows with similar semantics which would allow using a single codepath in the OCaml side.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be useful indeed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #6523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

running multiple instances of dune in parallel fails
6 participants