Skip to content

Support OTP 28 #5507

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

Merged
merged 3 commits into from
Apr 24, 2025
Merged

Support OTP 28 #5507

merged 3 commits into from
Apr 24, 2025

Conversation

janl
Copy link
Member

@janl janl commented Apr 18, 2025

based on -rc3

c.f. erlang/otp#9739

@janl
Copy link
Member Author

janl commented Apr 18, 2025

Update: fixed.

My local testing box (macOS 16.4.1/latest, arm64) with OTP-28-rc3 makes this test fail:

module 'chttpd_socket_buffer_size_test'
  chttpd socket_buffer_size_test
    chttpd_socket_buffer_size_test:67: -default_buffer/2-fun-1-...[0.023 s] ok
    chttpd_socket_buffer_size_test:51: -small_recbuf/2-fun-1-...*failed*
in function chttpd_socket_buffer_size_test:'-small_recbuf/2-fun-1-'/1 (test/eunit/chttpd_socket_buffer_size_test.erl, line 54)
in call from eunit_test:run_testfun/1 (eunit_test.erl, line 83)
in call from eunit_proc:run_test/1 (eunit_proc.erl, line 554)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 379)
in call from eunit_proc:handle_test/2 (eunit_proc.erl, line 537)
in call from eunit_proc:tests_inorder/3 (eunit_proc.erl, line 479)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 369)
in call from eunit_proc:run_group/2 (eunit_proc.erl, line 593)
**error:{assert,[{module,chttpd_socket_buffer_size_test},
         {line,54},
         {expression,"Response =:= 400 orelse Response =:= request_failed"},
         {expected,true},
         {value,false}]}
  output:<<"">>

In the logs, the expected-to-fail request shows a 201:

[notice] 2025-04-18T10:09:29.375779Z nonode@nohost <0.639.0> 8925f5c766 127.0.0.1:60869 127.0.0.1 chttpd_db_socket_buffer_size_test_admin PUT /eunit-test-db-145c735070a4bad74540e819cebb134e/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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->
    {timeout, 30,
        ?_test(begin
            Id = data(2048),
            Response = put_req(url(Db) ++ "/" ++ Id, "{}"),
            ?assert(Response =:= 400 orelse Response =:= request_failed)
        end)}.

I couldn’t find anything obvious in our or the OTP commits that could cause this.

The test passes with OTP-25 and -27 and -28-rc2.

@janl janl marked this pull request as draft April 18, 2025 11:39
@janl
Copy link
Member Author

janl commented Apr 18, 2025

Next, Mango:

The PCRE2 upgrade notes state:

Compiled Patterns Should Not be Shared: Sharing the result of re:compile/2 across node boundaries or persisting it has never been officially supported, although it might have accidentally worked between certain previous versions. The internal format produced by re:compile/2 has changed, and will not work on older OTP versions or across nodes. Relying on this undocumented behavior must be changed to compile the regular expression on the node instance where it is intended to be used.

This seems to include mochiglobal:put():

  mango_idx_text: indexable_fields_test...*failed*
in function erl_syntax:abstract/1 (erl_syntax.erl, line 7294)
in call from erl_syntax:abstract_list/1 (erl_syntax.erl, line 7297)
in call from erl_syntax:abstract_list/1 (erl_syntax.erl, line 7297)
in call from erl_syntax:abstract/1 (erl_syntax.erl, line 7280)
in call from mochiglobal:term_to_abstract/3 (src/mochiglobal.erl, line 95)
in call from mochiglobal:forms/2 (src/mochiglobal.erl, line 77)
in call from mochiglobal:compile/2 (src/mochiglobal.erl, line 71)
in call from mochiglobal:put/3 (src/mochiglobal.erl, line 51)
**error:{badarg,#Ref<0.2315338412.3477471233.154666>}
  output:<<"">>

This change to mango_util fixes the issues, but now we are not caching the compiled re:

 cached_re(Name, RE) ->
-    case mochiglobal:get(Name) of
-        undefined ->
-            {ok, MP} = re:compile(RE),
-            ok = mochiglobal:put(Name, MP),
-            MP;
-        MP ->
-            MP
-    end.
+    {ok, MP} = re:compile(RE),
+    MP. 

@janl
Copy link
Member Author

janl commented Apr 18, 2025

And then still in Mango, we get this a couple of times, seems we expect a reversal of some sort that is no longer happening. I haven’t had time to dig into this, but there were erl_syntax changes around reversal of lists in rc3, will update here when I know more:

The issue is that sets is now backed by maps by default and that changes the order of sets:to_list(), something we should not have relied on in the first place:

sets version 1:

Erlang/OTP 27 [erts-15.2.3] [source] [64-bit] [smp:14:14] [ds:14:14:10] [async-threads:1] [jit]

Eshell V15.2.3 (press Ctrl+G to abort, type help(). for help)
1> A = sets:from_list(["a","b", "c"]).
{set,3,16,16,8,80,48,
     {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
     {{[],
       ["b"],
       [],[],[],[],
       ["c"],
       [],[],[],[],[],
       ["a"],
       [],[],[]}}}
2> B = sets:from_list(["b"]).
{set,1,16,16,8,80,48,
     {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
     {{[],["b"],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}
3> sets:to_list(sets:subtract(A, B)).
["c","a"]

sets version 2:

Erlang/OTP 27 [erts-15.2.3] [source] [64-bit] [smp:14:14] [ds:14:14:10] [async-threads:1] [jit]

Eshell V15.2.3 (press Ctrl+G to abort, type help(). for help)
1> A = sets:from_list(["a","b", "c"], [{version, 2}]).
#{"a" => [],"b" => [],"c" => []}
2> B = sets:from_list(["b"], [{version, 2}]).
#{"b" => []}
3> sets:to_list(sets:subtract(A, B)).
["a","c"]

I pushed a quick fix that helps us pass the tests, but we might have to revisit, if we accidentally rely on the representation elsewhere.

 mango_cursor:1110: -extract_selector_hints_test_/0-fun-4- (t_extract_selector_hints_view)...*failed*
in function mango_cursor:t_extract_selector_hints_view/1 (src/mango_cursor.erl, line 1129)
in call from eunit_test:run_testfun/1 (eunit_test.erl, line 83)
in call from eunit_proc:run_test/1 (eunit_proc.erl, line 554)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 379)
in call from eunit_proc:handle_test/2 (eunit_proc.erl, line 537)
in call from eunit_proc:tests_inorder/3 (eunit_proc.erl, line 479)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 369)
in call from eunit_proc:run_group/2 (eunit_proc.erl, line 593)
**error:{assertEqual,[{module,mango_cursor},
              {line,1129},
              {expression,"extract_selector_hints ( selector )"},
              {expected,[{[{type,json},
                           {indexable_fields,["field2"]},
                           {unindexable_fields,["field3","field1"]}]}]},
              {value,[{[{type,json},
                        {indexable_fields,["field2"]},
                        {unindexable_fields,["field1","field3"]}]}]}]}
  output:<<"">>

Comment on lines 1116 to 1121
expect_set_from_list_ordered(L) ->
case erlang:system_info(otp_release) of
N when N >= "28" -> lists:sort(L);
_ -> L
end.

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of hard-coding OTP 28 checks in the test, the test should be improved to check that either the sets match or the the sorted lists of expected vs actual unindexable_fields match.

Copy link
Contributor

Choose a reason for hiding this comment

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

I gave it a try here #5510. It's a general improvement regardless of OTP version that just make us use all new sets and sorts the results to they are deterministic, otherwise tests might fail randomly again in the future

@nickva
Copy link
Contributor

nickva commented Apr 22, 2025

This pr should fix the mochiglobal issue. Thanks to @jaydoane for the review

nickva added a commit that referenced this pull request Apr 23, 2025
With OTP 28 sets switchd to using version 2 by default. That caused various
tests to fail, as Jan discovered in #5507

In the previous PR #5510 we switched few mango instances to use a helper
utility, but it was repeated a few times and Gábor made a good suggestion to
use utility functions instead, so that's what this PR does. But it does it for
the whole code base.

Once we're post OTP 28 we can remove the utility and just use plain set
functions.
@nickva nickva mentioned this pull request Apr 23, 2025
nickva added a commit that referenced this pull request Apr 23, 2025
With OTP 28 sets switchd to using version 2 by default. That caused various
tests to fail, as Jan discovered in #5507

In the previous PR #5510 we switched few mango instances to use a helper
utility, but it was repeated a few times and Gábor made a good suggestion to
use utility functions instead, so that's what this PR does. But it does it for
the whole code base.

Once we're post OTP 28 we can remove the utility and just use plain set
functions.
nickva added a commit that referenced this pull request Apr 23, 2025
With OTP 28 sets switchd to using version 2 by default. That caused various
tests to fail, as Jan discovered in #5507

In the previous PR #5510 we switched few mango instances to use a helper
utility, but it was repeated a few times and Gábor made a good suggestion to
use utility functions instead, so that's what this PR does. But it does it for
the whole code base.

Once we're post OTP 28 we can remove the utility and just use plain set
functions.
@janl
Copy link
Member Author

janl commented Apr 24, 2025

cleaned up the WIP work that @nickva has been properly fixing in the referenced commit. This should be ready to go now.

@janl janl marked this pull request as ready for review April 24, 2025 07:44
Copy link
Contributor

@big-r81 big-r81 left a comment

Choose a reason for hiding this comment

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

Nice work together! +1

Copy link
Contributor

@nickva nickva left a comment

Choose a reason for hiding this comment

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

+1 as well for a good team effort!

I see the elixir error only, same one found by Jan

00:43:38.923 [error] beam/beam_load.c(594): Error loading function 'Elixir.Hex.State':print_invalid_config_error/2: op bs_add p x x u x:
  please re-compile this module with an Erlang/OTP 28 compiler or update your Erlang/OTP version

That seems to be tracked in elixir-lang/elixir#14349

So it seems we'll just need to wait for OTP 28 to be released and the hex issue fixed to be able to add OTP 28 proper to the CI and build chain.

@janl janl merged commit 17bf647 into main Apr 24, 2025
23 checks passed
@janl janl deleted the feat/otp-28 branch April 24, 2025 14:21
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.

3 participants